diff options
author | Eric Biggers <ebiggers@google.com> | 2017-03-22 11:32:11 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-03-22 11:32:11 +0000 |
commit | 2bc9e957b28fd37939e79396ed784ed7c505da0d (patch) | |
tree | 4b5ebbb1e3c29f26f0167346e9b9d49d684a62fe /fs | |
parent | 9d0a150ea4c6535b6e95d291aeecf2d0d6e9315c (diff) | |
parent | 3a19419c50c6ee386ca6d22a23acc2df51583d3d (diff) |
fscrypto: lock inode while setting encryption policy
am: 3a19419c50
Change-Id: I3926f8d43c5d7f4c3648460bc103f24d05b6f3ee
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/ioctl.c | 4 | ||||
-rw-r--r-- | fs/f2fs/file.c | 9 |
2 files changed, 12 insertions, 1 deletions
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 7e974878d9a9..3a2594665b44 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -637,8 +637,12 @@ resizefs_out: if (err) goto encryption_policy_out; + mutex_lock(&inode->i_mutex); + err = ext4_process_policy(&policy, inode); + mutex_unlock(&inode->i_mutex); + mnt_drop_write_file(filp); encryption_policy_out: return err; diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index a197215ad52b..4b449d263333 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -1535,12 +1535,19 @@ static int f2fs_ioc_set_encryption_policy(struct file *filp, unsigned long arg) #ifdef CONFIG_F2FS_FS_ENCRYPTION struct f2fs_encryption_policy policy; struct inode *inode = file_inode(filp); + int err; if (copy_from_user(&policy, (struct f2fs_encryption_policy __user *)arg, sizeof(policy))) return -EFAULT; - return f2fs_process_policy(&policy, inode); + mutex_lock(&inode->i_mutex); + + err = f2fs_process_policy(&policy, inode); + + mutex_unlock(&inode->i_mutex); + + return err; #else return -EOPNOTSUPP; #endif |