diff options
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r-- | fs/compat_ioctl.c | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index debdfe0fc809..48f1987bec34 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -1531,16 +1531,13 @@ static int compat_ioctl_check_table(unsigned int xcmd) | |||
1531 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | 1531 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, |
1532 | unsigned long arg) | 1532 | unsigned long arg) |
1533 | { | 1533 | { |
1534 | struct file *filp; | 1534 | struct fd f = fdget(fd); |
1535 | int error = -EBADF; | 1535 | int error = -EBADF; |
1536 | int fput_needed; | 1536 | if (!f.file) |
1537 | |||
1538 | filp = fget_light(fd, &fput_needed); | ||
1539 | if (!filp) | ||
1540 | goto out; | 1537 | goto out; |
1541 | 1538 | ||
1542 | /* RED-PEN how should LSM module know it's handling 32bit? */ | 1539 | /* RED-PEN how should LSM module know it's handling 32bit? */ |
1543 | error = security_file_ioctl(filp, cmd, arg); | 1540 | error = security_file_ioctl(f.file, cmd, arg); |
1544 | if (error) | 1541 | if (error) |
1545 | goto out_fput; | 1542 | goto out_fput; |
1546 | 1543 | ||
@@ -1560,30 +1557,30 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
1560 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | 1557 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) |
1561 | case FS_IOC_RESVSP_32: | 1558 | case FS_IOC_RESVSP_32: |
1562 | case FS_IOC_RESVSP64_32: | 1559 | case FS_IOC_RESVSP64_32: |
1563 | error = compat_ioctl_preallocate(filp, compat_ptr(arg)); | 1560 | error = compat_ioctl_preallocate(f.file, compat_ptr(arg)); |
1564 | goto out_fput; | 1561 | goto out_fput; |
1565 | #else | 1562 | #else |
1566 | case FS_IOC_RESVSP: | 1563 | case FS_IOC_RESVSP: |
1567 | case FS_IOC_RESVSP64: | 1564 | case FS_IOC_RESVSP64: |
1568 | error = ioctl_preallocate(filp, compat_ptr(arg)); | 1565 | error = ioctl_preallocate(f.file, compat_ptr(arg)); |
1569 | goto out_fput; | 1566 | goto out_fput; |
1570 | #endif | 1567 | #endif |
1571 | 1568 | ||
1572 | case FIBMAP: | 1569 | case FIBMAP: |
1573 | case FIGETBSZ: | 1570 | case FIGETBSZ: |
1574 | case FIONREAD: | 1571 | case FIONREAD: |
1575 | if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) | 1572 | if (S_ISREG(f.file->f_path.dentry->d_inode->i_mode)) |
1576 | break; | 1573 | break; |
1577 | /*FALL THROUGH*/ | 1574 | /*FALL THROUGH*/ |
1578 | 1575 | ||
1579 | default: | 1576 | default: |
1580 | if (filp->f_op && filp->f_op->compat_ioctl) { | 1577 | if (f.file->f_op && f.file->f_op->compat_ioctl) { |
1581 | error = filp->f_op->compat_ioctl(filp, cmd, arg); | 1578 | error = f.file->f_op->compat_ioctl(f.file, cmd, arg); |
1582 | if (error != -ENOIOCTLCMD) | 1579 | if (error != -ENOIOCTLCMD) |
1583 | goto out_fput; | 1580 | goto out_fput; |
1584 | } | 1581 | } |
1585 | 1582 | ||
1586 | if (!filp->f_op || !filp->f_op->unlocked_ioctl) | 1583 | if (!f.file->f_op || !f.file->f_op->unlocked_ioctl) |
1587 | goto do_ioctl; | 1584 | goto do_ioctl; |
1588 | break; | 1585 | break; |
1589 | } | 1586 | } |
@@ -1591,7 +1588,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
1591 | if (compat_ioctl_check_table(XFORM(cmd))) | 1588 | if (compat_ioctl_check_table(XFORM(cmd))) |
1592 | goto found_handler; | 1589 | goto found_handler; |
1593 | 1590 | ||
1594 | error = do_ioctl_trans(fd, cmd, arg, filp); | 1591 | error = do_ioctl_trans(fd, cmd, arg, f.file); |
1595 | if (error == -ENOIOCTLCMD) | 1592 | if (error == -ENOIOCTLCMD) |
1596 | error = -ENOTTY; | 1593 | error = -ENOTTY; |
1597 | 1594 | ||
@@ -1600,9 +1597,9 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
1600 | found_handler: | 1597 | found_handler: |
1601 | arg = (unsigned long)compat_ptr(arg); | 1598 | arg = (unsigned long)compat_ptr(arg); |
1602 | do_ioctl: | 1599 | do_ioctl: |
1603 | error = do_vfs_ioctl(filp, fd, cmd, arg); | 1600 | error = do_vfs_ioctl(f.file, fd, cmd, arg); |
1604 | out_fput: | 1601 | out_fput: |
1605 | fput_light(filp, fput_needed); | 1602 | fdput(f); |
1606 | out: | 1603 | out: |
1607 | return error; | 1604 | return error; |
1608 | } | 1605 | } |