History

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

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

Linus Torvalds committed 6 years ago

Commit afdb0f22 parents 829f3b9 e3b107818 files · +737 −302Browse files

Showing the changes to include/linux (2 of 18 files). Show all

Unified · Split

2 files
  1. include/linux/fscrypt.h +126 −88
  2. include/linux/parser.h +4 −1
include/linux/fscrypt.h+126−88
@@ -15,12 +15,15 @@ · 14 unmodified lines
1515
1616 #include <linux/fs.h>
1717 #include <linux/mm.h>
18+#include <linux/parser.h>
1819 #include <linux/slab.h>
1920 #include <uapi/linux/fscrypt.h>
2021
2122 #define FS_CRYPTO_BLOCK_SIZE 16
2223
24+union fscrypt_context;
2325 struct fscrypt_info;
26+struct seq_file;
2427
2528 struct fscrypt_str {
2629 unsigned char *name;
@@ -56,10 +59,12 @@ struct fscrypt_name { · 29 unmodified lines
5659 struct fscrypt_operations {
5760 unsigned int flags;
5861 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);
6368 unsigned int max_namelen;
6469 bool (*has_stable_inodes)(struct super_block *sb);
6570 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
7580 /**
7681 * fscrypt_needs_contents_encryption() - check whether an inode needs
7782 * contents encryption
83+ * @inode: the inode to check
7884 *
7985 * Return: %true iff the inode is an encrypted regular file and the kernel was
8086 * built with fscrypt support.
@@ -87,10 +93,12 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) · 6 unmodified lines
8793 return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
8894 }
8995
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)
9198 {
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);
94102 }
95103
96104 /*
@@ -106,22 +114,21 @@ static inline void fscrypt_handle_d_move(struct dentry *dentry) · 9 unmodified lines
106114 }
107115
108116 /* 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);
125132
126133 static inline bool fscrypt_is_bounce_page(struct page *page)
127134 {
@@ -133,78 +140,90 @@ static inline struct page *fscrypt_pagecache_page(struct page *bounce_page) · 5 unmodified lines
133140 return (struct page *)page_private(bounce_page);
134141 }
135142
136−extern void fscrypt_free_bounce_page(struct page *bounce_page);
143+void fscrypt_free_bounce_page(struct page *bounce_page);
137144
138145 /* 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+
146170 /* 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);
153176
154177 /* 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);
159182
160183 /* 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);
163186
164187 static inline void fscrypt_free_filename(struct fscrypt_name *fname)
165188 {
166189 kfree(fname->crypto_buf.name);
167190 }
168191
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);
180202
181203 /* 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);
185207
186208 /* 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);
208227 static inline void fscrypt_set_ops(struct super_block *sb,
209228 const struct fscrypt_operations *s_cop)
210229 {
@@ -222,9 +241,10 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) · 11 unmodified lines
222241 return false;
223242 }
224243
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)
226246 {
227− return false;
247+ return NULL;
228248 }
229249
230250 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
319339 return -EOPNOTSUPP;
320340 }
321341
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+
322356 /* keyring.c */
323357 static inline void fscrypt_sb_free(struct super_block *sb)
324358 {
@@ -504,7 +538,7 @@ static inline void fscrypt_set_ops(struct super_block *sb, · 179 unmodified lines
504538 #endif /* !CONFIG_FS_ENCRYPTION */
505539
506540 /**
507− * fscrypt_require_key - require an inode's encryption key
541+ * fscrypt_require_key() - require an inode's encryption key
508542 * @inode: the inode we need the key for
509543 *
510544 * 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
530564 }
531565
532566 /**
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
534569 * @old_dentry: an existing dentry for the inode being linked
535570 * @dir: the target directory
536571 * @dentry: negative dentry for the target filename
@@ -557,7 +592,8 @@ static inline int fscrypt_prepare_link(struct dentry *old_dentry, · 20 unmodified lines
557592 }
558593
559594 /**
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
561597 * @old_dir: source directory
562598 * @old_dentry: dentry for source file
563599 * @new_dir: target directory
@@ -590,7 +626,8 @@ static inline int fscrypt_prepare_rename(struct inode *old_dir, · 26 unmodified lines
590626 }
591627
592628 /**
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
594631 * @dir: directory being searched
595632 * @dentry: filename being looked up
596633 * @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
623660 }
624661
625662 /**
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
627665 * @dentry: dentry through which the inode is being changed
628666 * @attr: attributes to change
629667 *
@@ -648,7 +686,7 @@ static inline int fscrypt_prepare_setattr(struct dentry *dentry, · 18 unmodified lines
648686 }
649687
650688 /**
651− * fscrypt_prepare_symlink - prepare to create a possibly-encrypted symlink
689+ * fscrypt_prepare_symlink() - prepare to create a possibly-encrypted symlink
652690 * @dir: directory in which the symlink is being created
653691 * @target: plaintext symlink target
654692 * @len: length of @target excluding null terminator
@@ -676,7 +714,7 @@ static inline int fscrypt_prepare_symlink(struct inode *dir, · 21 unmodified lines
676714 unsigned int max_len,
677715 struct fscrypt_str *disk_link)
678716 {
679− if (IS_ENCRYPTED(dir) || fscrypt_dummy_context_enabled(dir))
717+ if (IS_ENCRYPTED(dir) || fscrypt_get_dummy_context(dir->i_sb) != NULL)
680718 return __fscrypt_prepare_symlink(dir, len, max_len, disk_link);
681719
682720 disk_link->name = (unsigned char *)target;
@@ -687,7 +725,7 @@ static inline int fscrypt_prepare_symlink(struct inode *dir, · 4 unmodified lines
687725 }
688726
689727 /**
690− * fscrypt_encrypt_symlink - encrypt the symlink target if needed
728+ * fscrypt_encrypt_symlink() - encrypt the symlink target if needed
691729 * @inode: symlink inode
692730 * @target: plaintext symlink target
693731 * @len: length of @target excluding null terminator
include/linux/parser.h+4−1
@@ -7,7 +7,8 @@ · 6 unmodified lines
77 * but could potentially be used anywhere else that simple option=arg
88 * parsing is required.
99 */
10−
10+#ifndef _LINUX_PARSER_H
11+#define _LINUX_PARSER_H
1112
1213 /* associates an integer enumerator with a pattern string. */
1314 struct match_token {
@@ -34,3 +35,5 @@ int match_hex(substring_t *, int *result); · 20 unmodified lines
3435 bool match_wildcard(const char *pattern, const char *str);
3536 size_t match_strlcpy(char *, const substring_t *, size_t);
3637 char *match_strdup(const substring_t *);
38+
39+#endif /* _LINUX_PARSER_H */