diff options
Diffstat (limited to 'fs/compat_ioctl.c')
-rw-r--r-- | fs/compat_ioctl.c | 188 |
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 | |||
622 | static 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 | |||
651 | struct 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 | |||
657 | static 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 | |||
704 | struct 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 | |||
712 | static 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 | |||
737 | struct unimapdesc32 { | ||
738 | unsigned short entry_ct; | ||
739 | compat_caddr_t entries; | ||
740 | }; | ||
741 | |||
742 | static 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 | |||
775 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) | 620 | static 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) | |||
1333 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) | 1178 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) |
1334 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) | 1179 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) |
1335 | ULONG_IOCTL(SET_BITMAP_FILE) | 1180 | ULONG_IOCTL(SET_BITMAP_FILE) |
1336 | /* Big K */ | 1181 | /* Keyboard -- can be removed once tty3270 uses ops->compat_ioctl */ |
1337 | COMPATIBLE_IOCTL(PIO_FONT) | ||
1338 | COMPATIBLE_IOCTL(GIO_FONT) | ||
1339 | COMPATIBLE_IOCTL(PIO_CMAP) | ||
1340 | COMPATIBLE_IOCTL(GIO_CMAP) | ||
1341 | ULONG_IOCTL(KDSIGACCEPT) | 1182 | ULONG_IOCTL(KDSIGACCEPT) |
1342 | COMPATIBLE_IOCTL(KDGETKEYCODE) | 1183 | COMPATIBLE_IOCTL(KDGETKEYCODE) |
1343 | COMPATIBLE_IOCTL(KDSETKEYCODE) | 1184 | COMPATIBLE_IOCTL(KDSETKEYCODE) |
@@ -1361,12 +1202,6 @@ COMPATIBLE_IOCTL(KDGKBLED) | |||
1361 | ULONG_IOCTL(KDSKBLED) | 1202 | ULONG_IOCTL(KDSKBLED) |
1362 | COMPATIBLE_IOCTL(KDGETLED) | 1203 | COMPATIBLE_IOCTL(KDGETLED) |
1363 | ULONG_IOCTL(KDSETLED) | 1204 | ULONG_IOCTL(KDSETLED) |
1364 | COMPATIBLE_IOCTL(GIO_SCRNMAP) | ||
1365 | COMPATIBLE_IOCTL(PIO_SCRNMAP) | ||
1366 | COMPATIBLE_IOCTL(GIO_UNISCRNMAP) | ||
1367 | COMPATIBLE_IOCTL(PIO_UNISCRNMAP) | ||
1368 | COMPATIBLE_IOCTL(PIO_FONTRESET) | ||
1369 | COMPATIBLE_IOCTL(PIO_UNIMAPCLR) | ||
1370 | #ifdef CONFIG_BLOCK | 1205 | #ifdef CONFIG_BLOCK |
1371 | /* Big S */ | 1206 | /* Big S */ |
1372 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) | 1207 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) |
@@ -1378,20 +1213,6 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND) | |||
1378 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) | 1213 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) |
1379 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) | 1214 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) |
1380 | #endif | 1215 | #endif |
1381 | /* Big V */ | ||
1382 | COMPATIBLE_IOCTL(VT_SETMODE) | ||
1383 | COMPATIBLE_IOCTL(VT_GETMODE) | ||
1384 | COMPATIBLE_IOCTL(VT_GETSTATE) | ||
1385 | COMPATIBLE_IOCTL(VT_OPENQRY) | ||
1386 | ULONG_IOCTL(VT_ACTIVATE) | ||
1387 | ULONG_IOCTL(VT_WAITACTIVE) | ||
1388 | ULONG_IOCTL(VT_RELDISP) | ||
1389 | ULONG_IOCTL(VT_DISALLOCATE) | ||
1390 | COMPATIBLE_IOCTL(VT_RESIZE) | ||
1391 | COMPATIBLE_IOCTL(VT_RESIZEX) | ||
1392 | COMPATIBLE_IOCTL(VT_LOCKSWITCH) | ||
1393 | COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) | ||
1394 | COMPATIBLE_IOCTL(VT_GETHIFONTMASK) | ||
1395 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ | 1216 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ |
1396 | COMPATIBLE_IOCTL(RTC_AIE_ON) | 1217 | COMPATIBLE_IOCTL(RTC_AIE_ON) |
1397 | COMPATIBLE_IOCTL(RTC_AIE_OFF) | 1218 | COMPATIBLE_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) |
1895 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) | 1716 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) |
1896 | #ifdef CONFIG_VT | ||
1897 | HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) | ||
1898 | HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl) | ||
1899 | HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) | ||
1900 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) | ||
1901 | HANDLE_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) |
1905 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) | 1719 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) |