From: Chao Yu <chao@kernel.org>
To: tytso@mit.edu, adilger.kernel@dilger.ca
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org,
ebiggers@kernel.org, linux-fscrypt@vger.kernel.org,
chao@kernel.org, Chao Yu <yuchao0@huawei.com>
Subject: [PATCH] ext4 crypto: fix to check feature status before get policy
Date: Sun, 4 Aug 2019 17:56:43 +0800 [thread overview]
Message-ID: <20190804095643.7393-1-chao@kernel.org> (raw)
From: Chao Yu <yuchao0@huawei.com>
When getting fscrypto policy via EXT4_IOC_GET_ENCRYPTION_POLICY, if
encryption feature is off, it's better to return EOPNOTSUPP instead
of ENODATA, so let's add ext4_has_feature_encrypt() to do the check
for that.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
fs/ext4/ioctl.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 442f7ef873fc..bf87835c1237 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1112,9 +1112,11 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
return -EOPNOTSUPP;
#endif
}
- case EXT4_IOC_GET_ENCRYPTION_POLICY:
+ case EXT4_IOC_GET_ENCRYPTION_POLICY: {
+ if (!ext4_has_feature_encrypt(sb))
+ return -EOPNOTSUPP;
return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
-
+ }
case EXT4_IOC_FSGETXATTR:
{
struct fsxattr fa;
--
2.22.0
next reply other threads:[~2019-08-04 9:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-04 9:56 Chao Yu [this message]
2019-08-31 10:32 ` [PATCH] ext4 crypto: fix to check feature status before get policy Chao Yu
2019-08-31 15:02 ` Eric Biggers
2019-09-02 1:07 ` Chao Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190804095643.7393-1-chao@kernel.org \
--to=chao@kernel.org \
--cc=adilger.kernel@dilger.ca \
--cc=ebiggers@kernel.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=yuchao0@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).