Skip to contentSkip to conversation

fs/fuse: Fix matching of FUSE_DEV_IOC_CLONE command

PATCH Applied Alessio Balsini 2 participants 2 messages Mar 19, 2021 – Mar 22, 2021

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

PATCH 1/1 fs/fuse: Fix matching of FUSE_DEV_IOC_CLONE command

With commit f8425c939663 ("fuse: 32-bit user space ioctl compat for fuse device") the matching constraints for the FUSE_DEV_IOC_CLONE ioctl command are relaxed, limited to the testing of command type and number. As Arnd noticed, this is wrong as it wouldn't ensure the correctness of the data size or direction for the received FUSE device ioctl.

Fix by bringing back the comparison of the ioctl received by the FUSE device to the originally generated FUSE_DEV_IOC_CLONE.

Fixes f8425c939663 ("fuse: 32-bit user space ioctl compat for fuse device")
---
 fs/fuse/dev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/fuse/dev.c +2 -5
index c0fee830a34e..a5ceccc5ef00 100644
@@ -2233,11 +2233,8 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
 	int oldfd;
 	struct fuse_dev *fud = NULL;
 
-	if (_IOC_TYPE(cmd) != FUSE_DEV_IOC_MAGIC)
-		return -ENOTTY;
-
-	switch (_IOC_NR(cmd)) {
-	case _IOC_NR(FUSE_DEV_IOC_CLONE):
+	switch (cmd) {
+	case FUSE_DEV_IOC_CLONE:
 		res = -EFAULT;
 		if (!get_user(oldfd, (__u32 __user *)arg)) {
 			struct file *old = fget(oldfd);
Signature · 1 line
2.31.0.291.g576ba9dcdaf-goog
maintainer Applied
#1 lore raw
Quoted 7 lines · Alessio Balsini

With commit f8425c939663 ("fuse: 32-bit user space ioctl compat for fuse device") the matching constraints for the FUSE_DEV_IOC_CLONE ioctl command are relaxed, limited to the testing of command type and number. As Arnd noticed, this is wrong as it wouldn't ensure the correctness of the data size or direction for the received FUSE device ioctl.

Quoted 6 lines

Fix by bringing back the comparison of the ioctl received by the FUSE device to the originally generated FUSE_DEV_IOC_CLONE.

Fixes f8425c939663 ("fuse: 32-bit user space ioctl compat for fuse device")

Thanks, applied. I'm holding this till the 5.13 merge window unless
a more series fuse issue emerges in the meantime

Thanks,
Miklos