1 fscrypto: lock inode while setting encryption policy
3 From: Eric Biggers <ebiggers@google.com>
5 i_rwsem needs to be acquired while setting an encryption policy so that
6 concurrent calls to FS_IOC_SET_ENCRYPTION_POLICY are correctly
7 serialized (especially the ->get_context() + ->set_context() pair), and
8 so that new files cannot be created in the directory during or after the
11 Signed-off-by: Eric Biggers <ebiggers@google.com>
12 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 Reviewed-by: Richard Weinberger <richard@nod.at>
14 Cc: stable@vger.kernel.org
16 Note: to be applied without conflict, this patch needs the changes from
20 fs/crypto/policy.c | 4 ++++
21 1 file changed, 4 insertions(+)
23 diff --git a/fs/crypto/policy.c b/fs/crypto/policy.c
24 index ed115ac..6865663 100644
25 --- a/fs/crypto/policy.c
26 +++ b/fs/crypto/policy.c
27 @@ -109,6 +109,8 @@ int fscrypt_process_policy(struct file *filp,
33 if (!inode_has_encryption_context(inode)) {
34 if (!S_ISDIR(inode->i_mode))
36 @@ -127,6 +129,8 @@ int fscrypt_process_policy(struct file *filp,
40 + inode_unlock(inode);
42 mnt_drop_write_file(filp);
46 2.8.0.rc3.226.g39d4020