From: Theodore Ts'o Date: Sun, 31 May 2015 17:35:14 +0000 (-0400) Subject: ext4 crypto: policies may only be set on directories X-Git-Tag: v4.2-rc1~118^2~36 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d87f6d78e996bbba27b649c0e0eed7a37d6b73ba;p=thirdparty%2Fkernel%2Fstable.git ext4 crypto: policies may only be set on directories Thanks to Chao Yu for pointing out we were missing this check. Signed-off-by: Theodore Ts'o --- diff --git a/fs/ext4/crypto_policy.c b/fs/ext4/crypto_policy.c index 81980a158dc71..a1d434d0dea8f 100644 --- a/fs/ext4/crypto_policy.c +++ b/fs/ext4/crypto_policy.c @@ -93,6 +93,8 @@ int ext4_process_policy(const struct ext4_encryption_policy *policy, return -EINVAL; if (!ext4_inode_has_encryption_context(inode)) { + if (!S_ISDIR(inode->i_mode)) + return -EINVAL; if (!ext4_empty_dir(inode)) return -ENOTEMPTY; return ext4_create_encryption_context_from_policy(inode,