Pull fscrypt updates from Eric Biggers: - Add the IV_INO_LBLK_32 encryption policy flag which modifies the encryption to be optimized for eMMC inline encryption hardware. - Make the test_dummy_encryption mount option for ext4 and f2fs support v2 encryption policies. - Fix kerneldoc warnings and some coding style inconsistencies. * tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt: fscrypt: add support for IV_INO_LBLK_32 policies fscrypt: make test_dummy_encryption use v2 by default fscrypt: support test_dummy_encryption=v2 fscrypt: add fscrypt_add_test_dummy_key() linux/parser.h: add include guards fscrypt: remove unnecessary extern keywords fscrypt: name all function parameters fscrypt: fix all kerneldoc warnings
Showing the changes to include/linux (2 of 18 files). Show all
Unified · Split
| @@ -15,12 +15,15 @@ · 14 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | #include <linux/fs.h> |
| 17 | 17 | #include <linux/mm.h> |
| 18 | +#include <linux/parser.h> | |
| 18 | 19 | #include <linux/slab.h> |
| 19 | 20 | #include <uapi/linux/fscrypt.h> |
| 20 | 21 | |
| 21 | 22 | #define FS_CRYPTO_BLOCK_SIZE 16 |
| 22 | 23 | |
| 24 | +union fscrypt_context; | |
| 23 | 25 | struct fscrypt_info; |
| 26 | +struct seq_file; | |
| 24 | 27 | |
| 25 | 28 | struct fscrypt_str { |
| 26 | 29 | unsigned char *name; |
| @@ -56,10 +59,12 @@ struct fscrypt_name { · 29 unmodified lines | ||
| 56 | 59 | struct fscrypt_operations { |
| 57 | 60 | unsigned int flags; |
| 58 | 61 | const char *key_prefix; |
| 59 | − int (*get_context)(struct inode *, void *, size_t); | |
| 60 | − int (*set_context)(struct inode *, const void *, size_t, void *); | |
| 61 | − bool (*dummy_context)(struct inode *); | |
| 62 | − bool (*empty_dir)(struct inode *); | |
| 62 | + int (*get_context)(struct inode *inode, void *ctx, size_t len); | |
| 63 | + int (*set_context)(struct inode *inode, const void *ctx, size_t len, | |
| 64 | + void *fs_data); | |
| 65 | + const union fscrypt_context *(*get_dummy_context)( | |
| 66 | + struct super_block *sb); | |
| 67 | + bool (*empty_dir)(struct inode *inode); | |
| 63 | 68 | unsigned int max_namelen; |
| 64 | 69 | bool (*has_stable_inodes)(struct super_block *sb); |
| 65 | 70 | void (*get_ino_and_lblk_bits)(struct super_block *sb, |
| @@ -75,6 +80,7 @@ static inline bool fscrypt_has_encryption_key(const struct inode *inode) · 9 unmodified lines | ||
| 75 | 80 | /** |
| 76 | 81 | * fscrypt_needs_contents_encryption() - check whether an inode needs |
| 77 | 82 | * contents encryption |
| 83 | + * @inode: the inode to check | |
| 78 | 84 | * |
| 79 | 85 | * Return: %true iff the inode is an encrypted regular file and the kernel was |
| 80 | 86 | * built with fscrypt support. |
| @@ -87,10 +93,12 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) · 6 unmodified lines | ||
| 87 | 93 | return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode); |
| 88 | 94 | } |
| 89 | 95 | |
| 90 | −static inline bool fscrypt_dummy_context_enabled(struct inode *inode) | |
| 96 | +static inline const union fscrypt_context * | |
| 97 | +fscrypt_get_dummy_context(struct super_block *sb) | |
| 91 | 98 | { |
| 92 | − return inode->i_sb->s_cop->dummy_context && | |
| 93 | − inode->i_sb->s_cop->dummy_context(inode); | |
| 99 | + if (!sb->s_cop->get_dummy_context) | |
| 100 | + return NULL; | |
| 101 | + return sb->s_cop->get_dummy_context(sb); | |
| 94 | 102 | } |
| 95 | 103 | |
| 96 | 104 | /* |
| @@ -106,22 +114,21 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) · 9 unmodified lines | ||
| 106 | 114 | } |
| 107 | 115 | |
| 108 | 116 | /* crypto.c */ |
| 109 | −extern void fscrypt_enqueue_decrypt_work(struct work_struct *); | |
| 110 | − | |
| 111 | −extern struct page *fscrypt_encrypt_pagecache_blocks(struct page *page, | |
| 112 | − unsigned int len, | |
| 113 | − unsigned int offs, | |
| 114 | − gfp_t gfp_flags); | |
| 115 | −extern int fscrypt_encrypt_block_inplace(const struct inode *inode, | |
| 116 | − struct page *page, unsigned int len, | |
| 117 | − unsigned int offs, u64 lblk_num, | |
| 118 | − gfp_t gfp_flags); | |
| 119 | − | |
| 120 | −extern int fscrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len, | |
| 121 | − unsigned int offs); | |
| 122 | −extern int fscrypt_decrypt_block_inplace(const struct inode *inode, | |
| 123 | − struct page *page, unsigned int len, | |
| 124 | − unsigned int offs, u64 lblk_num); | |
| 117 | +void fscrypt_enqueue_decrypt_work(struct work_struct *); | |
| 118 | + | |
| 119 | +struct page *fscrypt_encrypt_pagecache_blocks(struct page *page, | |
| 120 | + unsigned int len, | |
| 121 | + unsigned int offs, | |
| 122 | + gfp_t gfp_flags); | |
| 123 | +int fscrypt_encrypt_block_inplace(const struct inode *inode, struct page *page, | |
| 124 | + unsigned int len, unsigned int offs, | |
| 125 | + u64 lblk_num, gfp_t gfp_flags); | |
| 126 | + | |
| 127 | +int fscrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len, | |
| 128 | + unsigned int offs); | |
| 129 | +int fscrypt_decrypt_block_inplace(const struct inode *inode, struct page *page, | |
| 130 | + unsigned int len, unsigned int offs, | |
| 131 | + u64 lblk_num); | |
| 125 | 132 | |
| 126 | 133 | static inline bool fscrypt_is_bounce_page(struct page *page) |
| 127 | 134 | { |
| @@ -133,78 +140,90 @@ static inline struct page *fscrypt_pagecache_page(struct page *bounce_page) · 5 unmodified lines | ||
| 133 | 140 | return (struct page *)page_private(bounce_page); |
| 134 | 141 | } |
| 135 | 142 | |
| 136 | −extern void fscrypt_free_bounce_page(struct page *bounce_page); | |
| 143 | +void fscrypt_free_bounce_page(struct page *bounce_page); | |
| 137 | 144 | |
| 138 | 145 | /* policy.c */ |
| 139 | −extern int fscrypt_ioctl_set_policy(struct file *, const void __user *); | |
| 140 | −extern int fscrypt_ioctl_get_policy(struct file *, void __user *); | |
| 141 | −extern int fscrypt_ioctl_get_policy_ex(struct file *, void __user *); | |
| 142 | −extern int fscrypt_ioctl_get_nonce(struct file *filp, void __user *arg); | |
| 143 | −extern int fscrypt_has_permitted_context(struct inode *, struct inode *); | |
| 144 | −extern int fscrypt_inherit_context(struct inode *, struct inode *, | |
| 145 | − void *, bool); | |
| 146 | +int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg); | |
| 147 | +int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg); | |
| 148 | +int fscrypt_ioctl_get_policy_ex(struct file *filp, void __user *arg); | |
| 149 | +int fscrypt_ioctl_get_nonce(struct file *filp, void __user *arg); | |
| 150 | +int fscrypt_has_permitted_context(struct inode *parent, struct inode *child); | |
| 151 | +int fscrypt_inherit_context(struct inode *parent, struct inode *child, | |
| 152 | + void *fs_data, bool preload); | |
| 153 | + | |
| 154 | +struct fscrypt_dummy_context { | |
| 155 | + const union fscrypt_context *ctx; | |
| 156 | +}; | |
| 157 | + | |
| 158 | +int fscrypt_set_test_dummy_encryption(struct super_block *sb, | |
| 159 | + const substring_t *arg, | |
| 160 | + struct fscrypt_dummy_context *dummy_ctx); | |
| 161 | +void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep, | |
| 162 | + struct super_block *sb); | |
| 163 | +static inline void | |
| 164 | +fscrypt_free_dummy_context(struct fscrypt_dummy_context *dummy_ctx) | |
| 165 | +{ | |
| 166 | + kfree(dummy_ctx->ctx); | |
| 167 | + dummy_ctx->ctx = NULL; | |
| 168 | +} | |
| 169 | + | |
| 146 | 170 | /* keyring.c */ |
| 147 | −extern void fscrypt_sb_free(struct super_block *sb); | |
| 148 | −extern int fscrypt_ioctl_add_key(struct file *filp, void __user *arg); | |
| 149 | −extern int fscrypt_ioctl_remove_key(struct file *filp, void __user *arg); | |
| 150 | −extern int fscrypt_ioctl_remove_key_all_users(struct file *filp, | |
| 151 | − void __user *arg); | |
| 152 | −extern int fscrypt_ioctl_get_key_status(struct file *filp, void __user *arg); | |
| 171 | +void fscrypt_sb_free(struct super_block *sb); | |
| 172 | +int fscrypt_ioctl_add_key(struct file *filp, void __user *arg); | |
| 173 | +int fscrypt_ioctl_remove_key(struct file *filp, void __user *arg); | |
| 174 | +int fscrypt_ioctl_remove_key_all_users(struct file *filp, void __user *arg); | |
| 175 | +int fscrypt_ioctl_get_key_status(struct file *filp, void __user *arg); | |
| 153 | 176 | |
| 154 | 177 | /* keysetup.c */ |
| 155 | −extern int fscrypt_get_encryption_info(struct inode *); | |
| 156 | −extern void fscrypt_put_encryption_info(struct inode *); | |
| 157 | −extern void fscrypt_free_inode(struct inode *); | |
| 158 | −extern int fscrypt_drop_inode(struct inode *inode); | |
| 178 | +int fscrypt_get_encryption_info(struct inode *inode); | |
| 179 | +void fscrypt_put_encryption_info(struct inode *inode); | |
| 180 | +void fscrypt_free_inode(struct inode *inode); | |
| 181 | +int fscrypt_drop_inode(struct inode *inode); | |
| 159 | 182 | |
| 160 | 183 | /* fname.c */ |
| 161 | −extern int fscrypt_setup_filename(struct inode *, const struct qstr *, | |
| 162 | − int lookup, struct fscrypt_name *); | |
| 184 | +int fscrypt_setup_filename(struct inode *inode, const struct qstr *iname, | |
| 185 | + int lookup, struct fscrypt_name *fname); | |
| 163 | 186 | |
| 164 | 187 | static inline void fscrypt_free_filename(struct fscrypt_name *fname) |
| 165 | 188 | { |
| 166 | 189 | kfree(fname->crypto_buf.name); |
| 167 | 190 | } |
| 168 | 191 | |
| 169 | −extern int fscrypt_fname_alloc_buffer(const struct inode *, u32, | |
| 170 | − struct fscrypt_str *); | |
| 171 | −extern void fscrypt_fname_free_buffer(struct fscrypt_str *); | |
| 172 | −extern int fscrypt_fname_disk_to_usr(const struct inode *inode, | |
| 173 | − u32 hash, u32 minor_hash, | |
| 174 | − const struct fscrypt_str *iname, | |
| 175 | − struct fscrypt_str *oname); | |
| 176 | −extern bool fscrypt_match_name(const struct fscrypt_name *fname, | |
| 177 | − const u8 *de_name, u32 de_name_len); | |
| 178 | −extern u64 fscrypt_fname_siphash(const struct inode *dir, | |
| 179 | − const struct qstr *name); | |
| 192 | +int fscrypt_fname_alloc_buffer(const struct inode *inode, u32 max_encrypted_len, | |
| 193 | + struct fscrypt_str *crypto_str); | |
| 194 | +void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str); | |
| 195 | +int fscrypt_fname_disk_to_usr(const struct inode *inode, | |
| 196 | + u32 hash, u32 minor_hash, | |
| 197 | + const struct fscrypt_str *iname, | |
| 198 | + struct fscrypt_str *oname); | |
| 199 | +bool fscrypt_match_name(const struct fscrypt_name *fname, | |
| 200 | + const u8 *de_name, u32 de_name_len); | |
| 201 | +u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name); | |
| 180 | 202 | |
| 181 | 203 | /* bio.c */ |
| 182 | −extern void fscrypt_decrypt_bio(struct bio *); | |
| 183 | −extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t, | |
| 184 | − unsigned int); | |
| 204 | +void fscrypt_decrypt_bio(struct bio *bio); | |
| 205 | +int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk, | |
| 206 | + sector_t pblk, unsigned int len); | |
| 185 | 207 | |
| 186 | 208 | /* hooks.c */ |
| 187 | −extern int fscrypt_file_open(struct inode *inode, struct file *filp); | |
| 188 | −extern int __fscrypt_prepare_link(struct inode *inode, struct inode *dir, | |
| 189 | − struct dentry *dentry); | |
| 190 | −extern int __fscrypt_prepare_rename(struct inode *old_dir, | |
| 191 | − struct dentry *old_dentry, | |
| 192 | − struct inode *new_dir, | |
| 193 | − struct dentry *new_dentry, | |
| 194 | − unsigned int flags); | |
| 195 | −extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry, | |
| 196 | − struct fscrypt_name *fname); | |
| 197 | −extern int fscrypt_prepare_setflags(struct inode *inode, | |
| 198 | − unsigned int oldflags, unsigned int flags); | |
| 199 | −extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len, | |
| 200 | − unsigned int max_len, | |
| 201 | − struct fscrypt_str *disk_link); | |
| 202 | −extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target, | |
| 203 | − unsigned int len, | |
| 204 | − struct fscrypt_str *disk_link); | |
| 205 | −extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr, | |
| 206 | − unsigned int max_size, | |
| 207 | − struct delayed_call *done); | |
| 209 | +int fscrypt_file_open(struct inode *inode, struct file *filp); | |
| 210 | +int __fscrypt_prepare_link(struct inode *inode, struct inode *dir, | |
| 211 | + struct dentry *dentry); | |
| 212 | +int __fscrypt_prepare_rename(struct inode *old_dir, struct dentry *old_dentry, | |
| 213 | + struct inode *new_dir, struct dentry *new_dentry, | |
| 214 | + unsigned int flags); | |
| 215 | +int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry, | |
| 216 | + struct fscrypt_name *fname); | |
| 217 | +int fscrypt_prepare_setflags(struct inode *inode, | |
| 218 | + unsigned int oldflags, unsigned int flags); | |
| 219 | +int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len, | |
| 220 | + unsigned int max_len, | |
| 221 | + struct fscrypt_str *disk_link); | |
| 222 | +int __fscrypt_encrypt_symlink(struct inode *inode, const char *target, | |
| 223 | + unsigned int len, struct fscrypt_str *disk_link); | |
| 224 | +const char *fscrypt_get_symlink(struct inode *inode, const void *caddr, | |
| 225 | + unsigned int max_size, | |
| 226 | + struct delayed_call *done); | |
| 208 | 227 | static inline void fscrypt_set_ops(struct super_block *sb, |
| 209 | 228 | const struct fscrypt_operations *s_cop) |
| 210 | 229 | { |
| @@ -222,9 +241,10 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) · 11 unmodified lines | ||
| 222 | 241 | return false; |
| 223 | 242 | } |
| 224 | 243 | |
| 225 | −static inline bool fscrypt_dummy_context_enabled(struct inode *inode) | |
| 244 | +static inline const union fscrypt_context * | |
| 245 | +fscrypt_get_dummy_context(struct super_block *sb) | |
| 226 | 246 | { |
| 227 | − return false; | |
| 247 | + return NULL; | |
| 228 | 248 | } |
| 229 | 249 | |
| 230 | 250 | static inline void fscrypt_handle_d_move(struct dentry *dentry) |
| @@ -319,6 +339,20 @@ static inline int fscrypt_inherit_context(struct inode *parent, · 88 unmodified lines | ||
| 319 | 339 | return -EOPNOTSUPP; |
| 320 | 340 | } |
| 321 | 341 | |
| 342 | +struct fscrypt_dummy_context { | |
| 343 | +}; | |
| 344 | + | |
| 345 | +static inline void fscrypt_show_test_dummy_encryption(struct seq_file *seq, | |
| 346 | + char sep, | |
| 347 | + struct super_block *sb) | |
| 348 | +{ | |
| 349 | +} | |
| 350 | + | |
| 351 | +static inline void | |
| 352 | +fscrypt_free_dummy_context(struct fscrypt_dummy_context *dummy_ctx) | |
| 353 | +{ | |
| 354 | +} | |
| 355 | + | |
| 322 | 356 | /* keyring.c */ |
| 323 | 357 | static inline void fscrypt_sb_free(struct super_block *sb) |
| 324 | 358 | { |
| @@ -504,7 +538,7 @@ static inline void fscrypt_set_ops(struct super_block *sb, · 179 unmodified lines | ||
| 504 | 538 | #endif /* !CONFIG_FS_ENCRYPTION */ |
| 505 | 539 | |
| 506 | 540 | /** |
| 507 | − * fscrypt_require_key - require an inode's encryption key | |
| 541 | + * fscrypt_require_key() - require an inode's encryption key | |
| 508 | 542 | * @inode: the inode we need the key for |
| 509 | 543 | * |
| 510 | 544 | * If the inode is encrypted, set up its encryption key if not already done. |
| @@ -530,7 +564,8 @@ static inline int fscrypt_require_key(struct inode *inode) · 19 unmodified lines | ||
| 530 | 564 | } |
| 531 | 565 | |
| 532 | 566 | /** |
| 533 | − * fscrypt_prepare_link - prepare to link an inode into a possibly-encrypted directory | |
| 567 | + * fscrypt_prepare_link() - prepare to link an inode into a possibly-encrypted | |
| 568 | + * directory | |
| 534 | 569 | * @old_dentry: an existing dentry for the inode being linked |
| 535 | 570 | * @dir: the target directory |
| 536 | 571 | * @dentry: negative dentry for the target filename |
| @@ -557,7 +592,8 @@ static inline int fscrypt_prepare_link(struct dentry *old_dentry, · 20 unmodified lines | ||
| 557 | 592 | } |
| 558 | 593 | |
| 559 | 594 | /** |
| 560 | − * fscrypt_prepare_rename - prepare for a rename between possibly-encrypted directories | |
| 595 | + * fscrypt_prepare_rename() - prepare for a rename between possibly-encrypted | |
| 596 | + * directories | |
| 561 | 597 | * @old_dir: source directory |
| 562 | 598 | * @old_dentry: dentry for source file |
| 563 | 599 | * @new_dir: target directory |
| @@ -590,7 +626,8 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir, · 26 unmodified lines | ||
| 590 | 626 | } |
| 591 | 627 | |
| 592 | 628 | /** |
| 593 | − * fscrypt_prepare_lookup - prepare to lookup a name in a possibly-encrypted directory | |
| 629 | + * fscrypt_prepare_lookup() - prepare to lookup a name in a possibly-encrypted | |
| 630 | + * directory | |
| 594 | 631 | * @dir: directory being searched |
| 595 | 632 | * @dentry: filename being looked up |
| 596 | 633 | * @fname: (output) the name to use to search the on-disk directory |
| @@ -623,7 +660,8 @@ static inline int fscrypt_prepare_lookup(struct inode *dir, · 26 unmodified lines | ||
| 623 | 660 | } |
| 624 | 661 | |
| 625 | 662 | /** |
| 626 | − * fscrypt_prepare_setattr - prepare to change a possibly-encrypted inode's attributes | |
| 663 | + * fscrypt_prepare_setattr() - prepare to change a possibly-encrypted inode's | |
| 664 | + * attributes | |
| 627 | 665 | * @dentry: dentry through which the inode is being changed |
| 628 | 666 | * @attr: attributes to change |
| 629 | 667 | * |
| @@ -648,7 +686,7 @@ static inline int fscrypt_prepare_setattr(struct dentry *dentry, · 18 unmodified lines | ||
| 648 | 686 | } |
| 649 | 687 | |
| 650 | 688 | /** |
| 651 | − * fscrypt_prepare_symlink - prepare to create a possibly-encrypted symlink | |
| 689 | + * fscrypt_prepare_symlink() - prepare to create a possibly-encrypted symlink | |
| 652 | 690 | * @dir: directory in which the symlink is being created |
| 653 | 691 | * @target: plaintext symlink target |
| 654 | 692 | * @len: length of @target excluding null terminator |
| @@ -676,7 +714,7 @@ static inline int fscrypt_prepare_symlink(struct inode *dir, · 21 unmodified lines | ||
| 676 | 714 | unsigned int max_len, |
| 677 | 715 | struct fscrypt_str *disk_link) |
| 678 | 716 | { |
| 679 | − if (IS_ENCRYPTED(dir) || fscrypt_dummy_context_enabled(dir)) | |
| 717 | + if (IS_ENCRYPTED(dir) || fscrypt_get_dummy_context(dir->i_sb) != NULL) | |
| 680 | 718 | return __fscrypt_prepare_symlink(dir, len, max_len, disk_link); |
| 681 | 719 | |
| 682 | 720 | disk_link->name = (unsigned char *)target; |
| @@ -687,7 +725,7 @@ static inline int fscrypt_prepare_symlink(struct inode *dir, · 4 unmodified lines | ||
| 687 | 725 | } |
| 688 | 726 | |
| 689 | 727 | /** |
| 690 | − * fscrypt_encrypt_symlink - encrypt the symlink target if needed | |
| 728 | + * fscrypt_encrypt_symlink() - encrypt the symlink target if needed | |
| 691 | 729 | * @inode: symlink inode |
| 692 | 730 | * @target: plaintext symlink target |
| 693 | 731 | * @len: length of @target excluding null terminator |
| @@ -7,7 +7,8 @@ · 6 unmodified lines | ||
| 7 | 7 | * but could potentially be used anywhere else that simple option=arg |
| 8 | 8 | * parsing is required. |
| 9 | 9 | */ |
| 10 | − | |
| 10 | +#ifndef _LINUX_PARSER_H | |
| 11 | +#define _LINUX_PARSER_H | |
| 11 | 12 | |
| 12 | 13 | /* associates an integer enumerator with a pattern string. */ |
| 13 | 14 | struct match_token { |
| @@ -34,3 +35,5 @@ int match_hex(substring_t *, int *result); · 20 unmodified lines | ||
| 34 | 35 | bool match_wildcard(const char *pattern, const char *str); |
| 35 | 36 | size_t match_strlcpy(char *, const substring_t *, size_t); |
| 36 | 37 | char *match_strdup(const substring_t *); |
| 38 | + | |
| 39 | +#endif /* _LINUX_PARSER_H */ | |