lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [day] [month] [year] [list]
Date:   Sun,  1 Jan 2017 12:04:28 +0100
From:   Fabian Frederick <fabf@...net.be>
To:     tytso@....edu, Andreas Dilger <adilger.kernel@...ger.ca>
Cc:     linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
        fabf@...net.be
Subject: [PATCH V2 1/2 linux-next] ext4: check inode permissions in ext4_ioctl()

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
get like EXT4_IOC_GETVERSION

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@...net.be>
---
V2: check readability in get operations only.

 fs/ext4/ioctl.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 49fd137..f665c02 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -453,6 +453,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 
 	switch (cmd) {
 	case EXT4_IOC_GETFLAGS:
+		if (inode_permission(inode, MAY_READ) != 0)
+			return -EACCES;
+
 		ext4_get_inode_flags(ei);
 		flags = ei->i_flags & EXT4_FL_USER_VISIBLE;
 		return put_user(flags, (int __user *) arg);
@@ -489,6 +492,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 	}
 	case EXT4_IOC_GETVERSION:
 	case EXT4_IOC_GETVERSION_OLD:
+		if (inode_permission(inode, MAY_READ) != 0)
+			return -EACCES;
+
 		return put_user(inode->i_generation, (int __user *) arg);
 	case EXT4_IOC_SETVERSION:
 	case EXT4_IOC_SETVERSION_OLD: {
@@ -834,12 +840,18 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
 #endif
 	}
 	case EXT4_IOC_GET_ENCRYPTION_POLICY:
+		if (inode_permission(inode, MAY_READ) != 0)
+			return -EACCES;
+
 		return fscrypt_ioctl_get_policy(filp, (void __user *)arg);
 
 	case EXT4_IOC_FSGETXATTR:
 	{
 		struct fsxattr fa;
 
+		if (inode_permission(inode, MAY_READ) != 0)
+			return -EACCES;
+
 		memset(&fa, 0, sizeof(struct fsxattr));
 		ext4_get_inode_flags(ei);
 		fa.fsx_xflags = ext4_iflags_to_xflags(ei->i_flags & EXT4_FL_USER_VISIBLE);
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ