History

Merge tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt

Pull fscrypt updates from Eric Biggers: - Preparations for supporting encryption on ext4 filesystems where the filesystem block size is smaller than PAGE_SIZE. - Don't allow setting encryption policies on dead directories. - Various cleanups. * tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt: fscrypt: document testing with xfstests fscrypt: remove selection of CONFIG_CRYPTO_SHA256 fscrypt: remove unnecessary includes of ratelimit.h fscrypt: don't set policy for a dead directory ext4: encrypt only up to last block in ext4_bio_write_page() ext4: decrypt only the needed block in __ext4_block_zero_page_range() ext4: decrypt only the needed blocks in ext4_block_write_begin() ext4: clear BH_Uptodate flag on decryption error fscrypt: decrypt only the needed blocks in __fscrypt_decrypt_bio() fscrypt: support decrypting multiple filesystem blocks per page fscrypt: introduce fscrypt_decrypt_block_inplace() fscrypt: handle blocksize < PAGE_SIZE in fscrypt_zeroout_range() fscrypt: support encrypting multiple filesystem blocks per page fscrypt: introduce fscrypt_encrypt_block_inplace() fscrypt: clean up some BUG_ON()s in block encryption/decryption fscrypt: rename fscrypt_do_page_crypto() to fscrypt_crypt_block() fscrypt: remove the "write" part of struct fscrypt_ctx fscrypt: simplify bounce page handling

Linus Torvalds committed 7 years ago

Commit 25cd6f32 parents 40f06c7 056433614 files · +363 −286Browse files

Showing the changes to include/linux (1 of 14 files). Show all

Unified · Split

include/linux/fscrypt.h+66−30
@@ -63,16 +63,13 @@ struct fscrypt_operations { · 62 unmodified lines
63 unsigned int max_namelen;63 unsigned int max_namelen;
64};64};
65 65
66/* Decryption work */
66struct fscrypt_ctx {67struct fscrypt_ctx {
67 union {68 union {
68 struct {
69 struct page *bounce_page; /* Ciphertext page */
70 struct page *control_page; /* Original page */
71 } w;
72 struct {69 struct {
73 struct bio *bio;70 struct bio *bio;
74 struct work_struct work;71 struct work_struct work;
75 } r;72 };
76 struct list_head free_list; /* Free list */73 struct list_head free_list; /* Free list */
77 };74 };
78 u8 flags; /* Flags */75 u8 flags; /* Flags */
@@ -106,18 +103,33 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) · 27 unmodified lines
106extern void fscrypt_enqueue_decrypt_work(struct work_struct *);103extern void fscrypt_enqueue_decrypt_work(struct work_struct *);
107extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t);104extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t);
108extern void fscrypt_release_ctx(struct fscrypt_ctx *);105extern void fscrypt_release_ctx(struct fscrypt_ctx *);
109extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *,
110 unsigned int, unsigned int,
111 u64, gfp_t);
112extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int,
113 unsigned int, u64);
114 106
115static inline struct page *fscrypt_control_page(struct page *page)107extern struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
108 unsigned int len,
109 unsigned int offs,
110 gfp_t gfp_flags);
111extern int fscrypt_encrypt_block_inplace(const struct inode *inode,
112 struct page *page, unsigned int len,
113 unsigned int offs, u64 lblk_num,
114 gfp_t gfp_flags);
115
116extern int fscrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len,
117 unsigned int offs);
118extern int fscrypt_decrypt_block_inplace(const struct inode *inode,
119 struct page *page, unsigned int len,
120 unsigned int offs, u64 lblk_num);
121
122static inline bool fscrypt_is_bounce_page(struct page *page)
123{
124 return page->mapping == NULL;
125}
126
127static inline struct page *fscrypt_pagecache_page(struct page *bounce_page)
116{128{
117 return ((struct fscrypt_ctx *)page_private(page))->w.control_page;129 return (struct page *)page_private(bounce_page);
118}130}
119 131
120extern void fscrypt_restore_control_page(struct page *);132extern void fscrypt_free_bounce_page(struct page *bounce_page);
121 133
122/* policy.c */134/* policy.c */
123extern int fscrypt_ioctl_set_policy(struct file *, const void __user *);135extern int fscrypt_ioctl_set_policy(struct file *, const void __user *);
@@ -223,7 +235,6 @@ static inline bool fscrypt_match_name(const struct fscrypt_name *fname, · 99 unmodified lines
223extern void fscrypt_decrypt_bio(struct bio *);235extern void fscrypt_decrypt_bio(struct bio *);
224extern void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,236extern void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
225 struct bio *bio);237 struct bio *bio);
226extern void fscrypt_pullback_bio_page(struct page **, bool);
227extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,238extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,
228 unsigned int);239 unsigned int);
229 240
@@ -283,32 +294,51 @@ static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) · 53 unmodified lines
283 return;294 return;
284}295}
285 296
286static inline struct page *fscrypt_encrypt_page(const struct inode *inode,297static inline struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
298 unsigned int len,
299 unsigned int offs,
300 gfp_t gfp_flags)
301{
302 return ERR_PTR(-EOPNOTSUPP);
303}
304
305static inline int fscrypt_encrypt_block_inplace(const struct inode *inode,
287 struct page *page,306 struct page *page,
288 unsigned int len,307 unsigned int len,
289 unsigned int offs,308 unsigned int offs, u64 lblk_num,
290 u64 lblk_num, gfp_t gfp_flags)309 gfp_t gfp_flags)
291{310{
292 return ERR_PTR(-EOPNOTSUPP);311 return -EOPNOTSUPP;
312}
313
314static inline int fscrypt_decrypt_pagecache_blocks(struct page *page,
315 unsigned int len,
316 unsigned int offs)
317{
318 return -EOPNOTSUPP;
293}319}
294 320
295static inline int fscrypt_decrypt_page(const struct inode *inode,321static inline int fscrypt_decrypt_block_inplace(const struct inode *inode,
296 struct page *page,322 struct page *page,
297 unsigned int len, unsigned int offs,323 unsigned int len,
298 u64 lblk_num)324 unsigned int offs, u64 lblk_num)
299{325{
300 return -EOPNOTSUPP;326 return -EOPNOTSUPP;
301}327}
302 328
303static inline struct page *fscrypt_control_page(struct page *page)329static inline bool fscrypt_is_bounce_page(struct page *page)
330{
331 return false;
332}
333
334static inline struct page *fscrypt_pagecache_page(struct page *bounce_page)
304{335{
305 WARN_ON_ONCE(1);336 WARN_ON_ONCE(1);
306 return ERR_PTR(-EINVAL);337 return ERR_PTR(-EINVAL);
307}338}
308 339
309static inline void fscrypt_restore_control_page(struct page *page)340static inline void fscrypt_free_bounce_page(struct page *bounce_page)
310{341{
311 return;
312}342}
313 343
314/* policy.c */344/* policy.c */
@@ -410,11 +440,6 @@ static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx, · 95 unmodified lines
410{440{
411}441}
412 442
413static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
414{
415 return;
416}
417
418static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,443static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
419 sector_t pblk, unsigned int len)444 sector_t pblk, unsigned int len)
420{445{
@@ -692,4 +717,15 @@ static inline int fscrypt_encrypt_symlink(struct inode *inode, · 271 unmodified lines
692 return 0;717 return 0;
693}718}
694 719
720/* If *pagep is a bounce page, free it and set *pagep to the pagecache page */
721static inline void fscrypt_finalize_bounce_page(struct page **pagep)
722{
723 struct page *page = *pagep;
724
725 if (fscrypt_is_bounce_page(page)) {
726 *pagep = fscrypt_pagecache_page(page);
727 fscrypt_free_bounce_page(page);
728 }
729}
730
695#endif /* _LINUX_FSCRYPT_H */731#endif /* _LINUX_FSCRYPT_H */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t