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
Showing the changes to include/linux (1 of 14 files). Show all
Unified · Split
| @@ -63,16 +63,13 @@ struct fscrypt_operations { · 62 unmodified lines | ||
| 63 | 63 | unsigned int max_namelen; |
| 64 | 64 | }; |
| 65 | 65 | |
| 66 | +/* Decryption work */ | |
| 66 | 67 | struct fscrypt_ctx { |
| 67 | 68 | union { |
| 68 | − struct { | |
| 69 | − struct page *bounce_page; /* Ciphertext page */ | |
| 70 | − struct page *control_page; /* Original page */ | |
| 71 | − } w; | |
| 72 | 69 | struct { |
| 73 | 70 | struct bio *bio; |
| 74 | 71 | struct work_struct work; |
| 75 | − } r; | |
| 72 | + }; | |
| 76 | 73 | struct list_head free_list; /* Free list */ |
| 77 | 74 | }; |
| 78 | 75 | u8 flags; /* Flags */ |
| @@ -106,18 +103,33 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) · 27 unmodified lines | ||
| 106 | 103 | extern void fscrypt_enqueue_decrypt_work(struct work_struct *); |
| 107 | 104 | extern struct fscrypt_ctx *fscrypt_get_ctx(gfp_t); |
| 108 | 105 | 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); | |
| 114 | 106 | |
| 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) | |
| 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 | |
| 120 | −extern void fscrypt_restore_control_page(struct page *); | |
| 132 | +extern void fscrypt_free_bounce_page(struct page *bounce_page); | |
| 121 | 133 | |
| 122 | 134 | /* policy.c */ |
| 123 | 135 | 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 | ||
| 223 | 235 | extern void fscrypt_decrypt_bio(struct bio *); |
| 224 | 236 | extern void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx, |
| 225 | 237 | struct bio *bio); |
| 226 | −extern void fscrypt_pullback_bio_page(struct page **, bool); | |
| 227 | 238 | extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t, |
| 228 | 239 | unsigned int); |
| 229 | 240 | |
| @@ -283,32 +294,51 @@ static inline void fscrypt_release_ctx(struct fscrypt_ctx *ctx) · 53 unmodified lines | ||
| 283 | 294 | return; |
| 284 | 295 | } |
| 285 | 296 | |
| 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, | |
| 287 | 306 | struct page *page, |
| 288 | 307 | 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) | |
| 291 | 310 | { |
| 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; | |
| 293 | 319 | } |
| 294 | 320 | |
| 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) | |
| 299 | 325 | { |
| 300 | 326 | return -EOPNOTSUPP; |
| 301 | 327 | } |
| 302 | 328 | |
| 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) | |
| 304 | 335 | { |
| 305 | 336 | WARN_ON_ONCE(1); |
| 306 | 337 | return ERR_PTR(-EINVAL); |
| 307 | 338 | } |
| 308 | 339 | |
| 309 | −static inline void fscrypt_restore_control_page(struct page *page) | |
| 340 | +static inline void fscrypt_free_bounce_page(struct page *bounce_page) | |
| 310 | 341 | { |
| 311 | − return; | |
| 312 | 342 | } |
| 313 | 343 | |
| 314 | 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 | |
| 413 | −static inline void fscrypt_pullback_bio_page(struct page **page, bool restore) | |
| 414 | −{ | |
| 415 | − return; | |
| 416 | −} | |
| 417 | − | |
| 418 | 443 | static inline int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, |
| 419 | 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 | 717 | return 0; |
| 693 | 718 | } |
| 694 | 719 | |
| 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 | + | |
| 695 | 731 | #endif /* _LINUX_FSCRYPT_H */ |