[1/2,linux-next] ext4: check inode permissions in ext4_ioctl()
diff mbox

Message ID 1483265786-21195-1-git-send-email-fabf@skynet.be
State New
Headers show

Commit Message

Fabian Frederick Jan. 1, 2017, 10:16 a.m. UTC
According to other FS like UDF, ioctl has to check if inode
is readable before proceeding otherwise permissions updated between
file opening and ioctl are ignored.

Set operations were already protected but nothing around

This patch applies the same test than udf_ioctl() but returns
-EACCES "permission denied" like the rest of ext4_ioctl()

Signed-off-by: Fabian Frederick <fabf@skynet.be>
 fs/ext4/ioctl.c | 3 +++
 1 file changed, 3 insertions(+)

diff mbox

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 49fd137..4f113e6 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -449,6 +449,9 @@  long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	struct ext4_inode_info *ei = EXT4_I(inode);
 	unsigned int flags;
+	if (inode_permission(inode, MAY_READ) != 0)
+		return -EACCES;
 	ext4_debug("cmd = %u, arg = %lu\n", cmd, arg);
 	switch (cmd) {