Skip to contentSkip to conversation

fuse: Set iov_len to sizeof(int) for FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls

PATCH In review Ratna Manoj Bolla 2 participants 2 messages Jul 10, 2024 – Aug 29, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fuse: Set iov_len to sizeof(int) for FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls

Hi,
User programs are passing integer pointers as argument to these ioctls. Many filesystems(xfs, ext) honour this to prevent corrupting the other four bytes.

This was discussed in the fsdevel mailing list with subject "Argument type for FS_IOC_GETFLAGS/FS_IOC_SETFLAGS ioctls"

Please see if we can be compatible by breaking correctness.

Thanks.

---
 fs/fuse/ioctl.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
fs/fuse/ioctl.c +10 -1
index 572ce8a82ceb..9e0ec0b3375e 100644
@@ -264,7 +264,16 @@ long fuse_do_ioctl(struct file *file, unsigned int cmd, unsigned long arg,
 		struct iovec *iov = iov_page;
 
 		iov->iov_base = (void __user *)arg;
-		iov->iov_len = _IOC_SIZE(cmd);
+
+		switch (cmd) {
+		case FS_IOC_GETFLAGS:
+		case FS_IOC_SETFLAGS:
+			iov->iov_len = sizeof(int);
+			break;
+		default:
+			iov->iov_len = _IOC_SIZE(cmd);
+			break;
+		}
 
 		if (_IOC_DIR(cmd) & _IOC_WRITE) {
 			in_iov = iov;
Signature · 1 line
2.43.5
maintainer
#1 lore raw
Quoted 8 lines · Ratna Manoj Bolla

Hi,
User programs are passing integer pointers as argument to these ioctls. Many filesystems(xfs, ext) honour this to prevent corrupting the other four bytes.

This was discussed in the fsdevel mailing list with subject "Argument type for FS_IOC_GETFLAGS/FS_IOC_SETFLAGS ioctls"

Please see if we can be compatible by breaking correctness.

I don't get it, FS_IOC_[GS]ETFLAGS is handled by the VFS since forever (v5.13 to be precise).

Thanks,
Miklos