Make insert_range return ENOTSUPP in preference to EINVAL to fix
[ext4-patch-queue.git] / policies-may-only-be-set-on-directories
blobcd6e974073ce3a4a6503aeb74ad724b29b7d45d3
1 ext4 crypto: policies may only be set on directories
3 Thanks to Chao Yu <chao2.yu@samsung.com> for pointing out we were
4 missing this check.
6 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
7 ---
8  fs/ext4/crypto_policy.c | 2 ++
9  1 file changed, 2 insertions(+)
11 diff --git a/fs/ext4/crypto_policy.c b/fs/ext4/crypto_policy.c
12 index 81980a15..a1d434d 100644
13 --- a/fs/ext4/crypto_policy.c
14 +++ b/fs/ext4/crypto_policy.c
15 @@ -93,6 +93,8 @@ int ext4_process_policy(const struct ext4_encryption_policy *policy,
16                 return -EINVAL;
18         if (!ext4_inode_has_encryption_context(inode)) {
19 +               if (!S_ISDIR(inode->i_mode))
20 +                       return -EINVAL;
21                 if (!ext4_empty_dir(inode))
22                         return -ENOTEMPTY;
23                 return ext4_create_encryption_context_from_policy(inode,