UPSTREAM: fuse: fix matching of FUSE_DEV_IOC_CLONE command
With commitf8425c9396
("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:f8425c9396
("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> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com> Signed-off-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Alessio Balsini <balsini@android.com> Change-Id: I372d8399db6d603ba20ef50528acf6645e4d3c66 (cherry picked from commit6076f5f341
)
This commit is contained in:
parent
37314b838d
commit
f5ec17375c
|
@ -2242,11 +2242,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);
|
||||
|
@ -2271,7 +2268,7 @@ static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case _IOC_NR(FUSE_DEV_IOC_PASSTHROUGH_OPEN):
|
||||
case FUSE_DEV_IOC_PASSTHROUGH_OPEN:
|
||||
res = -EFAULT;
|
||||
if (!get_user(oldfd, (__u32 __user *)arg)) {
|
||||
res = -EINVAL;
|
||||
|
|
Loading…
Reference in New Issue