aboutsummaryrefslogtreecommitdiffstats
path: root/fs/compat_ioctl.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2009-10-15 20:25:25 -0400
committerArnd Bergmann <arnd@arndb.de>2009-12-10 16:52:08 -0500
commitfb07a5f857ac8a2035d3f642317b0119b1056a7f (patch)
tree5aebb4e5218c39701a1acf13fea20c9782bbe78f /fs/compat_ioctl.c
parentd71cb81af3817193bc605de061da0499934263a6 (diff)
compat_ioctl: remove all VT ioctl handling
The VT driver now handles all of these ioctls directly, so we can remove the handlers from common code. These are the only handlers that require the BKL because they directly perform the ioctl action rather than just converting the data structures. Once they are gone, we can remove the BKL from the remaining ioctl conversion handlers. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r--fs/compat_ioctl.c188
1 files changed, 1 insertions, 187 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
index 2346895b3a77..6ad1c56a6c0e 100644
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -617,161 +617,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg)
617 617
618#endif /* CONFIG_BLOCK */ 618#endif /* CONFIG_BLOCK */
619 619
620#ifdef CONFIG_VT
621
622static int vt_check(struct file *file)
623{
624 struct tty_struct *tty;
625 struct inode *inode = file->f_path.dentry->d_inode;
626 struct vc_data *vc;
627
628 if (file->f_op->unlocked_ioctl != tty_ioctl)
629 return -EINVAL;
630
631 tty = (struct tty_struct *)file->private_data;
632 if (tty_paranoia_check(tty, inode, "tty_ioctl"))
633 return -EINVAL;
634
635 if (tty->ops->ioctl != vt_ioctl)
636 return -EINVAL;
637
638 vc = (struct vc_data *)tty->driver_data;
639 if (!vc_cons_allocated(vc->vc_num)) /* impossible? */
640 return -ENOIOCTLCMD;
641
642 /*
643 * To have permissions to do most of the vt ioctls, we either have
644 * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG.
645 */
646 if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG))
647 return 1;
648 return 0;
649}
650
651struct consolefontdesc32 {
652 unsigned short charcount; /* characters in font (256 or 512) */
653 unsigned short charheight; /* scan lines per character (1-32) */
654 compat_caddr_t chardata; /* font data in expanded form */
655};
656
657static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
658{
659 struct consolefontdesc32 __user *user_cfd = compat_ptr(arg);
660 struct console_font_op op;
661 compat_caddr_t data;
662 int i, perm;
663
664 perm = vt_check(file);
665 if (perm < 0) return perm;
666
667 switch (cmd) {
668 case PIO_FONTX:
669 if (!perm)
670 return -EPERM;
671 op.op = KD_FONT_OP_SET;
672 op.flags = 0;
673 op.width = 8;
674 if (get_user(op.height, &user_cfd->charheight) ||
675 get_user(op.charcount, &user_cfd->charcount) ||
676 get_user(data, &user_cfd->chardata))
677 return -EFAULT;
678 op.data = compat_ptr(data);
679 return con_font_op(vc_cons[fg_console].d, &op);
680 case GIO_FONTX:
681 op.op = KD_FONT_OP_GET;
682 op.flags = 0;
683 op.width = 8;
684 if (get_user(op.height, &user_cfd->charheight) ||
685 get_user(op.charcount, &user_cfd->charcount) ||
686 get_user(data, &user_cfd->chardata))
687 return -EFAULT;
688 if (!data)
689 return 0;
690 op.data = compat_ptr(data);
691 i = con_font_op(vc_cons[fg_console].d, &op);
692 if (i)
693 return i;
694 if (put_user(op.height, &user_cfd->charheight) ||
695 put_user(op.charcount, &user_cfd->charcount) ||
696 put_user((compat_caddr_t)(unsigned long)op.data,
697 &user_cfd->chardata))
698 return -EFAULT;
699 return 0;
700 }
701 return -EINVAL;
702}
703
704struct console_font_op32 {
705 compat_uint_t op; /* operation code KD_FONT_OP_* */
706 compat_uint_t flags; /* KD_FONT_FLAG_* */
707 compat_uint_t width, height; /* font size */
708 compat_uint_t charcount;
709 compat_caddr_t data; /* font data with height fixed to 32 */
710};
711
712static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
713{
714 struct console_font_op op;
715 struct console_font_op32 __user *fontop = compat_ptr(arg);
716 int perm = vt_check(file), i;
717 struct vc_data *vc;
718
719 if (perm < 0) return perm;
720
721 if (copy_from_user(&op, fontop, sizeof(struct console_font_op32)))
722 return -EFAULT;
723 if (!perm && op.op != KD_FONT_OP_GET)
724 return -EPERM;
725 op.data = compat_ptr(((struct console_font_op32 *)&op)->data);
726 op.flags |= KD_FONT_FLAG_OLD;
727 vc = ((struct tty_struct *)file->private_data)->driver_data;
728 i = con_font_op(vc, &op);
729 if (i)
730 return i;
731 ((struct console_font_op32 *)&op)->data = (unsigned long)op.data;
732 if (copy_to_user(fontop, &op, sizeof(struct console_font_op32)))
733 return -EFAULT;
734 return 0;
735}
736
737struct unimapdesc32 {
738 unsigned short entry_ct;
739 compat_caddr_t entries;
740};
741
742static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file)
743{
744 struct unimapdesc32 tmp;
745 struct unimapdesc32 __user *user_ud = compat_ptr(arg);
746 int perm = vt_check(file);
747 struct vc_data *vc;
748
749 if (perm < 0)
750 return perm;
751 if (copy_from_user(&tmp, user_ud, sizeof tmp))
752 return -EFAULT;
753 if (tmp.entries)
754 if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries),
755 tmp.entry_ct*sizeof(struct unipair)))
756 return -EFAULT;
757 vc = ((struct tty_struct *)file->private_data)->driver_data;
758 switch (cmd) {
759 case PIO_UNIMAP:
760 if (!perm)
761 return -EPERM;
762 return con_set_unimap(vc, tmp.entry_ct,
763 compat_ptr(tmp.entries));
764 case GIO_UNIMAP:
765 if (!perm && fg_console != vc->vc_num)
766 return -EPERM;
767 return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct),
768 compat_ptr(tmp.entries));
769 }
770 return 0;
771}
772
773#endif /* CONFIG_VT */
774
775static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) 620static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg)
776{ 621{
777 mm_segment_t old_fs = get_fs(); 622 mm_segment_t old_fs = get_fs();
@@ -1333,11 +1178,7 @@ COMPATIBLE_IOCTL(STOP_ARRAY_RO)
1333COMPATIBLE_IOCTL(RESTART_ARRAY_RW) 1178COMPATIBLE_IOCTL(RESTART_ARRAY_RW)
1334COMPATIBLE_IOCTL(GET_BITMAP_FILE) 1179COMPATIBLE_IOCTL(GET_BITMAP_FILE)
1335ULONG_IOCTL(SET_BITMAP_FILE) 1180ULONG_IOCTL(SET_BITMAP_FILE)
1336/* Big K */ 1181/* Keyboard -- can be removed once tty3270 uses ops->compat_ioctl */
1337COMPATIBLE_IOCTL(PIO_FONT)
1338COMPATIBLE_IOCTL(GIO_FONT)
1339COMPATIBLE_IOCTL(PIO_CMAP)
1340COMPATIBLE_IOCTL(GIO_CMAP)
1341ULONG_IOCTL(KDSIGACCEPT) 1182ULONG_IOCTL(KDSIGACCEPT)
1342COMPATIBLE_IOCTL(KDGETKEYCODE) 1183COMPATIBLE_IOCTL(KDGETKEYCODE)
1343COMPATIBLE_IOCTL(KDSETKEYCODE) 1184COMPATIBLE_IOCTL(KDSETKEYCODE)
@@ -1361,12 +1202,6 @@ COMPATIBLE_IOCTL(KDGKBLED)
1361ULONG_IOCTL(KDSKBLED) 1202ULONG_IOCTL(KDSKBLED)
1362COMPATIBLE_IOCTL(KDGETLED) 1203COMPATIBLE_IOCTL(KDGETLED)
1363ULONG_IOCTL(KDSETLED) 1204ULONG_IOCTL(KDSETLED)
1364COMPATIBLE_IOCTL(GIO_SCRNMAP)
1365COMPATIBLE_IOCTL(PIO_SCRNMAP)
1366COMPATIBLE_IOCTL(GIO_UNISCRNMAP)
1367COMPATIBLE_IOCTL(PIO_UNISCRNMAP)
1368COMPATIBLE_IOCTL(PIO_FONTRESET)
1369COMPATIBLE_IOCTL(PIO_UNIMAPCLR)
1370#ifdef CONFIG_BLOCK 1205#ifdef CONFIG_BLOCK
1371/* Big S */ 1206/* Big S */
1372COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) 1207COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
@@ -1378,20 +1213,6 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
1378COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) 1213COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
1379COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) 1214COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
1380#endif 1215#endif
1381/* Big V */
1382COMPATIBLE_IOCTL(VT_SETMODE)
1383COMPATIBLE_IOCTL(VT_GETMODE)
1384COMPATIBLE_IOCTL(VT_GETSTATE)
1385COMPATIBLE_IOCTL(VT_OPENQRY)
1386ULONG_IOCTL(VT_ACTIVATE)
1387ULONG_IOCTL(VT_WAITACTIVE)
1388ULONG_IOCTL(VT_RELDISP)
1389ULONG_IOCTL(VT_DISALLOCATE)
1390COMPATIBLE_IOCTL(VT_RESIZE)
1391COMPATIBLE_IOCTL(VT_RESIZEX)
1392COMPATIBLE_IOCTL(VT_LOCKSWITCH)
1393COMPATIBLE_IOCTL(VT_UNLOCKSWITCH)
1394COMPATIBLE_IOCTL(VT_GETHIFONTMASK)
1395/* Little p (/dev/rtc, /dev/envctrl, etc.) */ 1216/* Little p (/dev/rtc, /dev/envctrl, etc.) */
1396COMPATIBLE_IOCTL(RTC_AIE_ON) 1217COMPATIBLE_IOCTL(RTC_AIE_ON)
1397COMPATIBLE_IOCTL(RTC_AIE_OFF) 1218COMPATIBLE_IOCTL(RTC_AIE_OFF)
@@ -1893,13 +1714,6 @@ HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans)
1893#endif 1714#endif
1894#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) 1715#define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int)
1895HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) 1716HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout)
1896#ifdef CONFIG_VT
1897HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl)
1898HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl)
1899HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl)
1900HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl)
1901HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl)
1902#endif
1903/* One SMB ioctl needs translations. */ 1717/* One SMB ioctl needs translations. */
1904#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) 1718#define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t)
1905HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) 1719HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid)