linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/fuse: Fix matching of FUSE_DEV_IOC_CLONE command
@ 2021-03-19 15:05 Alessio Balsini
  2021-03-22 15:04 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Alessio Balsini @ 2021-03-19 15:05 UTC (permalink / raw)
  To: Arnd Bergmann, Miklos Szeredi; +Cc: kernel-team, linux-fsdevel, linux-kernel

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")
Reported-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Alessio Balsini <balsini@android.com>
---
 fs/fuse/dev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index c0fee830a34e..a5ceccc5ef00 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -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);
-- 
2.31.0.291.g576ba9dcdaf-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fs/fuse: Fix matching of FUSE_DEV_IOC_CLONE command
  2021-03-19 15:05 [PATCH] fs/fuse: Fix matching of FUSE_DEV_IOC_CLONE command Alessio Balsini
@ 2021-03-22 15:04 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2021-03-22 15:04 UTC (permalink / raw)
  To: Alessio Balsini; +Cc: Arnd Bergmann, kernel-team, linux-fsdevel, linux-kernel

On Fri, Mar 19, 2021 at 4:06 PM Alessio Balsini <balsini@android.com> wrote:
>
> 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")
> Reported-by: Arnd Bergmann <arnd@kernel.org>
> Signed-off-by: Alessio Balsini <balsini@android.com>

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

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-03-22 15:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 15:05 [PATCH] fs/fuse: Fix matching of FUSE_DEV_IOC_CLONE command Alessio Balsini
2021-03-22 15:04 ` Miklos Szeredi

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).