aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat_ioctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r--fs/compat_ioctl.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index debdfe0fc809..f5054025f9da 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -866,6 +866,12 @@ COMPATIBLE_IOCTL(TIOCGPTN)
866COMPATIBLE_IOCTL(TIOCSPTLCK) 866COMPATIBLE_IOCTL(TIOCSPTLCK)
867COMPATIBLE_IOCTL(TIOCSERGETLSR) 867COMPATIBLE_IOCTL(TIOCSERGETLSR)
868COMPATIBLE_IOCTL(TIOCSIG) 868COMPATIBLE_IOCTL(TIOCSIG)
869#ifdef TIOCSRS485
870COMPATIBLE_IOCTL(TIOCSRS485)
871#endif
872#ifdef TIOCGRS485
873COMPATIBLE_IOCTL(TIOCGRS485)
874#endif
869#ifdef TCGETS2 875#ifdef TCGETS2
870COMPATIBLE_IOCTL(TCGETS2) 876COMPATIBLE_IOCTL(TCGETS2)
871COMPATIBLE_IOCTL(TCSETS2) 877COMPATIBLE_IOCTL(TCSETS2)
@@ -897,6 +903,8 @@ COMPATIBLE_IOCTL(KDGKBSENT)
897COMPATIBLE_IOCTL(KDSKBSENT) 903COMPATIBLE_IOCTL(KDSKBSENT)
898COMPATIBLE_IOCTL(KDGKBDIACR) 904COMPATIBLE_IOCTL(KDGKBDIACR)
899COMPATIBLE_IOCTL(KDSKBDIACR) 905COMPATIBLE_IOCTL(KDSKBDIACR)
906COMPATIBLE_IOCTL(KDGKBDIACRUC)
907COMPATIBLE_IOCTL(KDSKBDIACRUC)
900COMPATIBLE_IOCTL(KDKBDREP) 908COMPATIBLE_IOCTL(KDKBDREP)
901COMPATIBLE_IOCTL(KDGKBLED) 909COMPATIBLE_IOCTL(KDGKBLED)
902COMPATIBLE_IOCTL(KDGETLED) 910COMPATIBLE_IOCTL(KDGETLED)
@@ -1531,16 +1539,13 @@ static int compat_ioctl_check_table(unsigned int xcmd)
1531asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, 1539asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1532 unsigned long arg) 1540 unsigned long arg)
1533{ 1541{
1534 struct file *filp; 1542 struct fd f = fdget(fd);
1535 int error = -EBADF; 1543 int error = -EBADF;
1536 int fput_needed; 1544 if (!f.file)
1537
1538 filp = fget_light(fd, &fput_needed);
1539 if (!filp)
1540 goto out; 1545 goto out;
1541 1546
1542 /* RED-PEN how should LSM module know it's handling 32bit? */ 1547 /* RED-PEN how should LSM module know it's handling 32bit? */
1543 error = security_file_ioctl(filp, cmd, arg); 1548 error = security_file_ioctl(f.file, cmd, arg);
1544 if (error) 1549 if (error)
1545 goto out_fput; 1550 goto out_fput;
1546 1551
@@ -1560,30 +1565,30 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1560#if defined(CONFIG_IA64) || defined(CONFIG_X86_64) 1565#if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
1561 case FS_IOC_RESVSP_32: 1566 case FS_IOC_RESVSP_32:
1562 case FS_IOC_RESVSP64_32: 1567 case FS_IOC_RESVSP64_32:
1563 error = compat_ioctl_preallocate(filp, compat_ptr(arg)); 1568 error = compat_ioctl_preallocate(f.file, compat_ptr(arg));
1564 goto out_fput; 1569 goto out_fput;
1565#else 1570#else
1566 case FS_IOC_RESVSP: 1571 case FS_IOC_RESVSP:
1567 case FS_IOC_RESVSP64: 1572 case FS_IOC_RESVSP64:
1568 error = ioctl_preallocate(filp, compat_ptr(arg)); 1573 error = ioctl_preallocate(f.file, compat_ptr(arg));
1569 goto out_fput; 1574 goto out_fput;
1570#endif 1575#endif
1571 1576
1572 case FIBMAP: 1577 case FIBMAP:
1573 case FIGETBSZ: 1578 case FIGETBSZ:
1574 case FIONREAD: 1579 case FIONREAD:
1575 if (S_ISREG(filp->f_path.dentry->d_inode->i_mode)) 1580 if (S_ISREG(f.file->f_path.dentry->d_inode->i_mode))
1576 break; 1581 break;
1577 /*FALL THROUGH*/ 1582 /*FALL THROUGH*/
1578 1583
1579 default: 1584 default:
1580 if (filp->f_op && filp->f_op->compat_ioctl) { 1585 if (f.file->f_op && f.file->f_op->compat_ioctl) {
1581 error = filp->f_op->compat_ioctl(filp, cmd, arg); 1586 error = f.file->f_op->compat_ioctl(f.file, cmd, arg);
1582 if (error != -ENOIOCTLCMD) 1587 if (error != -ENOIOCTLCMD)
1583 goto out_fput; 1588 goto out_fput;
1584 } 1589 }
1585 1590
1586 if (!filp->f_op || !filp->f_op->unlocked_ioctl) 1591 if (!f.file->f_op || !f.file->f_op->unlocked_ioctl)
1587 goto do_ioctl; 1592 goto do_ioctl;
1588 break; 1593 break;
1589 } 1594 }
@@ -1591,7 +1596,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1591 if (compat_ioctl_check_table(XFORM(cmd))) 1596 if (compat_ioctl_check_table(XFORM(cmd)))
1592 goto found_handler; 1597 goto found_handler;
1593 1598
1594 error = do_ioctl_trans(fd, cmd, arg, filp); 1599 error = do_ioctl_trans(fd, cmd, arg, f.file);
1595 if (error == -ENOIOCTLCMD) 1600 if (error == -ENOIOCTLCMD)
1596 error = -ENOTTY; 1601 error = -ENOTTY;
1597 1602
@@ -1600,9 +1605,9 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
1600 found_handler: 1605 found_handler:
1601 arg = (unsigned long)compat_ptr(arg); 1606 arg = (unsigned long)compat_ptr(arg);
1602 do_ioctl: 1607 do_ioctl:
1603 error = do_vfs_ioctl(filp, fd, cmd, arg); 1608 error = do_vfs_ioctl(f.file, fd, cmd, arg);
1604 out_fput: 1609 out_fput:
1605 fput_light(filp, fput_needed); 1610 fdput(f);
1606 out: 1611 out:
1607 return error; 1612 return error;
1608} 1613}