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
15 15
16#include <linux/fs.h>16#include <linux/fs.h>
17#include <linux/mm.h>17#include <linux/mm.h>
18#include <linux/parser.h>
18#include <linux/slab.h>19#include <linux/slab.h>
19#include <uapi/linux/fscrypt.h>20#include <uapi/linux/fscrypt.h>
20 21
21#define FS_CRYPTO_BLOCK_SIZE 1622#define FS_CRYPTO_BLOCK_SIZE 16
22 23
24union fscrypt_context;
23struct fscrypt_info;25struct fscrypt_info;
26struct seq_file;
24 27
25struct fscrypt_str {28struct fscrypt_str {
26 unsigned char *name;29 unsigned char *name;
@@ -56,10 +59,12 @@ struct fscrypt_name { · 29 unmodified lines
56struct fscrypt_operations {59struct fscrypt_operations {
57 unsigned int flags;60 unsigned int flags;
58 const char *key_prefix;61 const char *key_prefix;
59 int (*get_context)(struct inode *, void *, size_t);62 int (*get_context)(struct inode *inode, void *ctx, size_t len);
60 int (*set_context)(struct inode *, const void *, size_t, void *);63 int (*set_context)(struct inode *inode, const void *ctx, size_t len,
61 bool (*dummy_context)(struct inode *);64 void *fs_data);
62 bool (*empty_dir)(struct inode *);65 const union fscrypt_context *(*get_dummy_context)(
66 struct super_block *sb);
67 bool (*empty_dir)(struct inode *inode);
63 unsigned int max_namelen;68 unsigned int max_namelen;
64 bool (*has_stable_inodes)(struct super_block *sb);69 bool (*has_stable_inodes)(struct super_block *sb);
65 void (*get_ino_and_lblk_bits)(struct super_block *sb,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 * fscrypt_needs_contents_encryption() - check whether an inode needs81 * fscrypt_needs_contents_encryption() - check whether an inode needs
77 * contents encryption82 * contents encryption
83 * @inode: the inode to check
78 *84 *
79 * Return: %true iff the inode is an encrypted regular file and the kernel was85 * Return: %true iff the inode is an encrypted regular file and the kernel was
80 * built with fscrypt support.86 * built with fscrypt support.
@@ -87,10 +93,12 @@ static inline bool fscrypt_needs_contents_encryption(const struct inode *inode) · 6 unmodified lines
87 return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);93 return IS_ENCRYPTED(inode) && S_ISREG(inode->i_mode);
88}94}
89 95
90static inline bool fscrypt_dummy_context_enabled(struct inode *inode)96static inline const union fscrypt_context *
97fscrypt_get_dummy_context(struct super_block *sb)
91{98{
92 return inode->i_sb->s_cop->dummy_context &&99 if (!sb->s_cop->get_dummy_context)
93 inode->i_sb->s_cop->dummy_context(inode);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/* crypto.c */116/* crypto.c */
109extern void fscrypt_enqueue_decrypt_work(struct work_struct *);117void fscrypt_enqueue_decrypt_work(struct work_struct *);
110 118
111extern struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,119struct page *fscrypt_encrypt_pagecache_blocks(struct page *page,
112 unsigned int len,120 unsigned int len,
113 unsigned int offs,121 unsigned int offs,
114 gfp_t gfp_flags);122 gfp_t gfp_flags);
115extern int fscrypt_encrypt_block_inplace(const struct inode *inode,123int fscrypt_encrypt_block_inplace(const struct inode *inode, struct page *page,
116 struct page *page, unsigned int len,124 unsigned int len, unsigned int offs,
117 unsigned int offs, u64 lblk_num,125 u64 lblk_num, gfp_t gfp_flags);
118 gfp_t gfp_flags);126
119 127int fscrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len,
120extern int fscrypt_decrypt_pagecache_blocks(struct page *page, unsigned int len,128 unsigned int offs);
121 unsigned int offs);129int fscrypt_decrypt_block_inplace(const struct inode *inode, struct page *page,
122extern int fscrypt_decrypt_block_inplace(const struct inode *inode,130 unsigned int len, unsigned int offs,
123 struct page *page, unsigned int len,131 u64 lblk_num);
124 unsigned int offs, u64 lblk_num);
125 132
126static inline bool fscrypt_is_bounce_page(struct page *page)133static 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 return (struct page *)page_private(bounce_page);140 return (struct page *)page_private(bounce_page);
134}141}
135 142
136extern void fscrypt_free_bounce_page(struct page *bounce_page);143void fscrypt_free_bounce_page(struct page *bounce_page);
137 144
138/* policy.c */145/* policy.c */
139extern int fscrypt_ioctl_set_policy(struct file *, const void __user *);146int fscrypt_ioctl_set_policy(struct file *filp, const void __user *arg);
140extern int fscrypt_ioctl_get_policy(struct file *, void __user *);147int fscrypt_ioctl_get_policy(struct file *filp, void __user *arg);
141extern int fscrypt_ioctl_get_policy_ex(struct file *, void __user *);148int fscrypt_ioctl_get_policy_ex(struct file *filp, void __user *arg);
142extern int fscrypt_ioctl_get_nonce(struct file *filp, void __user *arg);149int fscrypt_ioctl_get_nonce(struct file *filp, void __user *arg);
143extern int fscrypt_has_permitted_context(struct inode *, struct inode *);150int fscrypt_has_permitted_context(struct inode *parent, struct inode *child);
144extern int fscrypt_inherit_context(struct inode *, struct inode *,151int fscrypt_inherit_context(struct inode *parent, struct inode *child,
145 void *, bool);152 void *fs_data, bool preload);
153
154struct fscrypt_dummy_context {
155 const union fscrypt_context *ctx;
156};
157
158int fscrypt_set_test_dummy_encryption(struct super_block *sb,
159 const substring_t *arg,
160 struct fscrypt_dummy_context *dummy_ctx);
161void fscrypt_show_test_dummy_encryption(struct seq_file *seq, char sep,
162 struct super_block *sb);
163static inline void
164fscrypt_free_dummy_context(struct fscrypt_dummy_context *dummy_ctx)
165{
166 kfree(dummy_ctx->ctx);
167 dummy_ctx->ctx = NULL;
168}
169
146/* keyring.c */170/* keyring.c */
147extern void fscrypt_sb_free(struct super_block *sb);171void fscrypt_sb_free(struct super_block *sb);
148extern int fscrypt_ioctl_add_key(struct file *filp, void __user *arg);172int fscrypt_ioctl_add_key(struct file *filp, void __user *arg);
149extern int fscrypt_ioctl_remove_key(struct file *filp, void __user *arg);173int fscrypt_ioctl_remove_key(struct file *filp, void __user *arg);
150extern int fscrypt_ioctl_remove_key_all_users(struct file *filp,174int fscrypt_ioctl_remove_key_all_users(struct file *filp, void __user *arg);
151 void __user *arg);175int fscrypt_ioctl_get_key_status(struct file *filp, void __user *arg);
152extern int fscrypt_ioctl_get_key_status(struct file *filp, void __user *arg);
153 176
154/* keysetup.c */177/* keysetup.c */
155extern int fscrypt_get_encryption_info(struct inode *);178int fscrypt_get_encryption_info(struct inode *inode);
156extern void fscrypt_put_encryption_info(struct inode *);179void fscrypt_put_encryption_info(struct inode *inode);
157extern void fscrypt_free_inode(struct inode *);180void fscrypt_free_inode(struct inode *inode);
158extern int fscrypt_drop_inode(struct inode *inode);181int fscrypt_drop_inode(struct inode *inode);
159 182
160/* fname.c */183/* fname.c */
161extern int fscrypt_setup_filename(struct inode *, const struct qstr *,184int fscrypt_setup_filename(struct inode *inode, const struct qstr *iname,
162 int lookup, struct fscrypt_name *);185 int lookup, struct fscrypt_name *fname);
163 186
164static inline void fscrypt_free_filename(struct fscrypt_name *fname)187static inline void fscrypt_free_filename(struct fscrypt_name *fname)
165{188{
166 kfree(fname->crypto_buf.name);189 kfree(fname->crypto_buf.name);
167}190}
168 191
169extern int fscrypt_fname_alloc_buffer(const struct inode *, u32,192int fscrypt_fname_alloc_buffer(const struct inode *inode, u32 max_encrypted_len,
170 struct fscrypt_str *);193 struct fscrypt_str *crypto_str);
171extern void fscrypt_fname_free_buffer(struct fscrypt_str *);194void fscrypt_fname_free_buffer(struct fscrypt_str *crypto_str);
172extern int fscrypt_fname_disk_to_usr(const struct inode *inode,195int fscrypt_fname_disk_to_usr(const struct inode *inode,
173 u32 hash, u32 minor_hash,196 u32 hash, u32 minor_hash,
174 const struct fscrypt_str *iname,197 const struct fscrypt_str *iname,
175 struct fscrypt_str *oname);198 struct fscrypt_str *oname);
176extern bool fscrypt_match_name(const struct fscrypt_name *fname,199bool fscrypt_match_name(const struct fscrypt_name *fname,
177 const u8 *de_name, u32 de_name_len);200 const u8 *de_name, u32 de_name_len);
178extern u64 fscrypt_fname_siphash(const struct inode *dir,201u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name);
179 const struct qstr *name);
180 202
181/* bio.c */203/* bio.c */
182extern void fscrypt_decrypt_bio(struct bio *);204void fscrypt_decrypt_bio(struct bio *bio);
183extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,205int fscrypt_zeroout_range(const struct inode *inode, pgoff_t lblk,
184 unsigned int);206 sector_t pblk, unsigned int len);
185 207
186/* hooks.c */208/* hooks.c */
187extern int fscrypt_file_open(struct inode *inode, struct file *filp);209int fscrypt_file_open(struct inode *inode, struct file *filp);
188extern int __fscrypt_prepare_link(struct inode *inode, struct inode *dir,210int __fscrypt_prepare_link(struct inode *inode, struct inode *dir,
189 struct dentry *dentry);211 struct dentry *dentry);
190extern int __fscrypt_prepare_rename(struct inode *old_dir,212int __fscrypt_prepare_rename(struct inode *old_dir, struct dentry *old_dentry,
191 struct dentry *old_dentry,213 struct inode *new_dir, struct dentry *new_dentry,
192 struct inode *new_dir,214 unsigned int flags);
193 struct dentry *new_dentry,215int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry,
194 unsigned int flags);216 struct fscrypt_name *fname);
195extern int __fscrypt_prepare_lookup(struct inode *dir, struct dentry *dentry,217int fscrypt_prepare_setflags(struct inode *inode,
196 struct fscrypt_name *fname);218 unsigned int oldflags, unsigned int flags);
197extern int fscrypt_prepare_setflags(struct inode *inode,219int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len,
198 unsigned int oldflags, unsigned int flags);220 unsigned int max_len,
199extern int __fscrypt_prepare_symlink(struct inode *dir, unsigned int len,221 struct fscrypt_str *disk_link);
200 unsigned int max_len,222int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,
201 struct fscrypt_str *disk_link);223 unsigned int len, struct fscrypt_str *disk_link);
202extern int __fscrypt_encrypt_symlink(struct inode *inode, const char *target,224const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
203 unsigned int len,225 unsigned int max_size,
204 struct fscrypt_str *disk_link);226 struct delayed_call *done);
205extern const char *fscrypt_get_symlink(struct inode *inode, const void *caddr,
206 unsigned int max_size,
207 struct delayed_call *done);
208static inline void fscrypt_set_ops(struct super_block *sb,227static inline void fscrypt_set_ops(struct super_block *sb,
209 const struct fscrypt_operations *s_cop)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 return false;241 return false;
223}242}
224 243
225static inline bool fscrypt_dummy_context_enabled(struct inode *inode)244static inline const union fscrypt_context *
245fscrypt_get_dummy_context(struct super_block *sb)
226{246{
227 return false;247 return NULL;
228}248}
229 249
230static inline void fscrypt_handle_d_move(struct dentry *dentry)250static 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 return -EOPNOTSUPP;339 return -EOPNOTSUPP;
320}340}
321 341
342struct fscrypt_dummy_context {
343};
344
345static inline void fscrypt_show_test_dummy_encryption(struct seq_file *seq,
346 char sep,
347 struct super_block *sb)
348{
349}
350
351static inline void
352fscrypt_free_dummy_context(struct fscrypt_dummy_context *dummy_ctx)
353{
354}
355
322/* keyring.c */356/* keyring.c */
323static inline void fscrypt_sb_free(struct super_block *sb)357static 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#endif /* !CONFIG_FS_ENCRYPTION */538#endif /* !CONFIG_FS_ENCRYPTION */
505 539
506/**540/**
507 * fscrypt_require_key - require an inode's encryption key541 * fscrypt_require_key() - require an inode's encryption key
508 * @inode: the inode we need the key for542 * @inode: the inode we need the key for
509 *543 *
510 * If the inode is encrypted, set up its encryption key if not already done.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 directory567 * fscrypt_prepare_link() - prepare to link an inode into a possibly-encrypted
568 * directory
534 * @old_dentry: an existing dentry for the inode being linked569 * @old_dentry: an existing dentry for the inode being linked
535 * @dir: the target directory570 * @dir: the target directory
536 * @dentry: negative dentry for the target filename571 * @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 directories595 * fscrypt_prepare_rename() - prepare for a rename between possibly-encrypted
596 * directories
561 * @old_dir: source directory597 * @old_dir: source directory
562 * @old_dentry: dentry for source file598 * @old_dentry: dentry for source file
563 * @new_dir: target directory599 * @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 directory629 * fscrypt_prepare_lookup() - prepare to lookup a name in a possibly-encrypted
630 * directory
594 * @dir: directory being searched631 * @dir: directory being searched
595 * @dentry: filename being looked up632 * @dentry: filename being looked up
596 * @fname: (output) the name to use to search the on-disk directory633 * @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 attributes663 * fscrypt_prepare_setattr() - prepare to change a possibly-encrypted inode's
664 * attributes
627 * @dentry: dentry through which the inode is being changed665 * @dentry: dentry through which the inode is being changed
628 * @attr: attributes to change666 * @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 symlink689 * fscrypt_prepare_symlink() - prepare to create a possibly-encrypted symlink
652 * @dir: directory in which the symlink is being created690 * @dir: directory in which the symlink is being created
653 * @target: plaintext symlink target691 * @target: plaintext symlink target
654 * @len: length of @target excluding null terminator692 * @len: length of @target excluding null terminator
@@ -676,7 +714,7 @@ static inline int fscrypt_prepare_symlink(struct inode *dir, · 21 unmodified lines
676 unsigned int max_len,714 unsigned int max_len,
677 struct fscrypt_str *disk_link)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 return __fscrypt_prepare_symlink(dir, len, max_len, disk_link);718 return __fscrypt_prepare_symlink(dir, len, max_len, disk_link);
681 719
682 disk_link->name = (unsigned char *)target;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 needed728 * fscrypt_encrypt_symlink() - encrypt the symlink target if needed
691 * @inode: symlink inode729 * @inode: symlink inode
692 * @target: plaintext symlink target730 * @target: plaintext symlink target
693 * @len: length of @target excluding null terminator731 * @len: length of @target excluding null terminator
include/linux/parser.h+4−1
@@ -7,7 +7,8 @@ · 6 unmodified lines
7 * but could potentially be used anywhere else that simple option=arg7 * but could potentially be used anywhere else that simple option=arg
8 * parsing is required.8 * parsing is required.
9 */9 */
10 10#ifndef _LINUX_PARSER_H
11#define _LINUX_PARSER_H
11 12
12/* associates an integer enumerator with a pattern string. */13/* associates an integer enumerator with a pattern string. */
13struct match_token {14struct match_token {
@@ -34,3 +35,5 @@ int match_hex(substring_t *, int *result); · 20 unmodified lines
34bool match_wildcard(const char *pattern, const char *str);35bool match_wildcard(const char *pattern, const char *str);
35size_t match_strlcpy(char *, const substring_t *, size_t);36size_t match_strlcpy(char *, const substring_t *, size_t);
36char *match_strdup(const substring_t *);37char *match_strdup(const substring_t *);
38
39#endif /* _LINUX_PARSER_H */