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
6363 unsigned int max_namelen;
6464 };
6565
66+/* Decryption work */
6667 struct fscrypt_ctx {
6768 union {
68− struct {
69− struct page *bounce_page; /* Ciphertext page */
70− struct page *control_page; /* Original page */
71− } w;
7269 struct {
7370 struct bio *bio;
7471 struct work_struct work;
75− } r;
72+ };
7673 struct list_head free_list; /* Free list */
7774 };
7875 u8 flags; /* Flags */
@@ -106,18 +103,33 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) · 27 unmodified lines
106103 extern void fscrypt_enqueue_decrypt_work(struct work_struct *);
107104 extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t);
108105 extern void fscrypt_release_ctx(struct fscrypt_ctx *);
109−extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *,
110− unsigned int, unsigned int,
111− u64, gfp_t);
112−extern int fscrypt_decrypt_page(const struct inode *, struct page *, unsigned int,
113− unsigned int, u64);
114106
115−static inline struct page *fscrypt_control_page(struct page *page)
107+extern struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
108+ unsigned int len,
109+ unsigned int offs,
110+ gfp_t gfp_flags);
111+extern 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+
116+extern int fscrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len,
117+ unsigned int offs);
118+extern int fscrypt_decrypt_block_inplace(const struct inode *inode,
119+ struct page *page, unsigned int len,
120+ unsigned int offs, u64 lblk_num);
121+
122+static inline bool fscrypt_is_bounce_page(struct page *page)
123+{
124+ return page->mapping == NULL;
125+}
126+
127+static inline struct page *fscrypt_pagecache_page(struct page *bounce_page)
116128 {
117− return ((struct fscrypt_ctx *)page_private(page))->w.control_page;
129+ return (struct page *)page_private(bounce_page);
118130 }
119131
120−extern void fscrypt_restore_control_page(struct page *);
132+extern void fscrypt_free_bounce_page(struct page *bounce_page);
121133
122134 /* policy.c */
123135 extern 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
223235 extern void fscrypt_decrypt_bio(struct bio *);
224236 extern void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
225237 struct bio *bio);
226−extern void fscrypt_pullback_bio_page(struct page **, bool);
227238 extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,
228239 unsigned int);
229240
@@ -283,32 +294,51 @@ static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) · 53 unmodified lines
283294 return;
284295 }
285296
286−static inline struct page *fscrypt_encrypt_page(const struct inode *inode,
297+static 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+
305+static inline int fscrypt_encrypt_block_inplace(const struct inode *inode,
287306 struct page *page,
288307 unsigned int len,
289− unsigned int offs,
290− u64 lblk_num, gfp_t gfp_flags)
308+ unsigned int offs, u64 lblk_num,
309+ gfp_t gfp_flags)
291310 {
292− return ERR_PTR(-EOPNOTSUPP);
311+ return -EOPNOTSUPP;
312+}
313+
314+static inline int fscrypt_decrypt_pagecache_blocks(struct page *page,
315+ unsigned int len,
316+ unsigned int offs)
317+{
318+ return -EOPNOTSUPP;
293319 }
294320
295−static inline int fscrypt_decrypt_page(const struct inode *inode,
296− struct page *page,
297− unsigned int len, unsigned int offs,
298− u64 lblk_num)
321+static inline int fscrypt_decrypt_block_inplace(const struct inode *inode,
322+ struct page *page,
323+ unsigned int len,
324+ unsigned int offs, u64 lblk_num)
299325 {
300326 return -EOPNOTSUPP;
301327 }
302328
303−static inline struct page *fscrypt_control_page(struct page *page)
329+static inline bool fscrypt_is_bounce_page(struct page *page)
330+{
331+ return false;
332+}
333+
334+static inline struct page *fscrypt_pagecache_page(struct page *bounce_page)
304335 {
305336 WARN_ON_ONCE(1);
306337 return ERR_PTR(-EINVAL);
307338 }
308339
309−static inline void fscrypt_restore_control_page(struct page *page)
340+static inline void fscrypt_free_bounce_page(struct page *bounce_page)
310341 {
311− return;
312342 }
313343
314344 /* policy.c */
@@ -410,11 +440,6 @@ static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx, · 95 unmodified lines
410440 {
411441 }
412442
413−static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
414−{
415− return;
416−}
417−
418443 static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
419444 sector_t pblk, unsigned int len)
420445 {
@@ -692,4 +717,15 @@ static inline int fscrypt_encrypt_symlink(struct inode *inode, · 271 unmodified lines
692717 return 0;
693718 }
694719
720+/* If *pagep is a bounce page, free it and set *pagep to the pagecache page */
721+static 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+
695731 #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