diff options
-rw-r--r-- | block/compat_ioctl.c | 83 | ||||
-rw-r--r-- | fs/compat_ioctl.c | 105 |
2 files changed, 83 insertions, 105 deletions
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index 44807d38b1e7..92b3e8d07ca6 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
@@ -92,6 +92,84 @@ static int compat_hdio_ioctl(struct inode *inode, struct file *file, | |||
92 | return error; | 92 | return error; |
93 | } | 93 | } |
94 | 94 | ||
95 | struct compat_cdrom_read_audio { | ||
96 | union cdrom_addr addr; | ||
97 | u8 addr_format; | ||
98 | compat_int_t nframes; | ||
99 | compat_caddr_t buf; | ||
100 | }; | ||
101 | |||
102 | struct compat_cdrom_generic_command { | ||
103 | unsigned char cmd[CDROM_PACKET_SIZE]; | ||
104 | compat_caddr_t buffer; | ||
105 | compat_uint_t buflen; | ||
106 | compat_int_t stat; | ||
107 | compat_caddr_t sense; | ||
108 | unsigned char data_direction; | ||
109 | compat_int_t quiet; | ||
110 | compat_int_t timeout; | ||
111 | compat_caddr_t reserved[1]; | ||
112 | }; | ||
113 | |||
114 | static int compat_cdrom_read_audio(struct inode *inode, struct file *file, | ||
115 | struct gendisk *disk, unsigned int cmd, unsigned long arg) | ||
116 | { | ||
117 | struct cdrom_read_audio __user *cdread_audio; | ||
118 | struct compat_cdrom_read_audio __user *cdread_audio32; | ||
119 | __u32 data; | ||
120 | void __user *datap; | ||
121 | |||
122 | cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio)); | ||
123 | cdread_audio32 = compat_ptr(arg); | ||
124 | |||
125 | if (copy_in_user(&cdread_audio->addr, | ||
126 | &cdread_audio32->addr, | ||
127 | (sizeof(*cdread_audio32) - | ||
128 | sizeof(compat_caddr_t)))) | ||
129 | return -EFAULT; | ||
130 | |||
131 | if (get_user(data, &cdread_audio32->buf)) | ||
132 | return -EFAULT; | ||
133 | datap = compat_ptr(data); | ||
134 | if (put_user(datap, &cdread_audio->buf)) | ||
135 | return -EFAULT; | ||
136 | |||
137 | return blkdev_driver_ioctl(inode, file, disk, cmd, | ||
138 | (unsigned long)cdread_audio); | ||
139 | } | ||
140 | |||
141 | static int compat_cdrom_generic_command(struct inode *inode, struct file *file, | ||
142 | struct gendisk *disk, unsigned int cmd, unsigned long arg) | ||
143 | { | ||
144 | struct cdrom_generic_command __user *cgc; | ||
145 | struct compat_cdrom_generic_command __user *cgc32; | ||
146 | u32 data; | ||
147 | unsigned char dir; | ||
148 | int itmp; | ||
149 | |||
150 | cgc = compat_alloc_user_space(sizeof(*cgc)); | ||
151 | cgc32 = compat_ptr(arg); | ||
152 | |||
153 | if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) || | ||
154 | get_user(data, &cgc32->buffer) || | ||
155 | put_user(compat_ptr(data), &cgc->buffer) || | ||
156 | copy_in_user(&cgc->buflen, &cgc32->buflen, | ||
157 | (sizeof(unsigned int) + sizeof(int))) || | ||
158 | get_user(data, &cgc32->sense) || | ||
159 | put_user(compat_ptr(data), &cgc->sense) || | ||
160 | get_user(dir, &cgc32->data_direction) || | ||
161 | put_user(dir, &cgc->data_direction) || | ||
162 | get_user(itmp, &cgc32->quiet) || | ||
163 | put_user(itmp, &cgc->quiet) || | ||
164 | get_user(itmp, &cgc32->timeout) || | ||
165 | put_user(itmp, &cgc->timeout) || | ||
166 | get_user(data, &cgc32->reserved[0]) || | ||
167 | put_user(compat_ptr(data), &cgc->reserved[0])) | ||
168 | return -EFAULT; | ||
169 | |||
170 | return blkdev_driver_ioctl(inode, file, disk, cmd, (unsigned long)cgc); | ||
171 | } | ||
172 | |||
95 | struct compat_blkpg_ioctl_arg { | 173 | struct compat_blkpg_ioctl_arg { |
96 | compat_int_t op; | 174 | compat_int_t op; |
97 | compat_int_t flags; | 175 | compat_int_t flags; |
@@ -190,6 +268,11 @@ static int compat_blkdev_driver_ioctl(struct inode *inode, struct file *file, | |||
190 | case HDIO_GET_ADDRESS: | 268 | case HDIO_GET_ADDRESS: |
191 | case HDIO_GET_BUSSTATE: | 269 | case HDIO_GET_BUSSTATE: |
192 | return compat_hdio_ioctl(inode, file, disk, cmd, arg); | 270 | return compat_hdio_ioctl(inode, file, disk, cmd, arg); |
271 | case CDROMREADAUDIO: | ||
272 | return compat_cdrom_read_audio(inode, file, disk, cmd, arg); | ||
273 | case CDROM_SEND_PACKET: | ||
274 | return compat_cdrom_generic_command(inode, file, disk, cmd, arg); | ||
275 | |||
193 | /* | 276 | /* |
194 | * No handler required for the ones below, we just need to | 277 | * No handler required for the ones below, we just need to |
195 | * convert arg to a 64 bit pointer. | 278 | * convert arg to a 64 bit pointer. |
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 3baa90d31090..24c743571127 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -37,7 +37,6 @@ | |||
37 | #include <linux/if_ppp.h> | 37 | #include <linux/if_ppp.h> |
38 | #include <linux/if_pppox.h> | 38 | #include <linux/if_pppox.h> |
39 | #include <linux/mtio.h> | 39 | #include <linux/mtio.h> |
40 | #include <linux/cdrom.h> | ||
41 | #include <linux/auto_fs.h> | 40 | #include <linux/auto_fs.h> |
42 | #include <linux/auto_fs4.h> | 41 | #include <linux/auto_fs4.h> |
43 | #include <linux/tty.h> | 42 | #include <linux/tty.h> |
@@ -1039,108 +1038,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
1039 | return err ? -EFAULT: 0; | 1038 | return err ? -EFAULT: 0; |
1040 | } | 1039 | } |
1041 | 1040 | ||
1042 | struct cdrom_read_audio32 { | ||
1043 | union cdrom_addr addr; | ||
1044 | u8 addr_format; | ||
1045 | compat_int_t nframes; | ||
1046 | compat_caddr_t buf; | ||
1047 | }; | ||
1048 | |||
1049 | struct cdrom_generic_command32 { | ||
1050 | unsigned char cmd[CDROM_PACKET_SIZE]; | ||
1051 | compat_caddr_t buffer; | ||
1052 | compat_uint_t buflen; | ||
1053 | compat_int_t stat; | ||
1054 | compat_caddr_t sense; | ||
1055 | unsigned char data_direction; | ||
1056 | compat_int_t quiet; | ||
1057 | compat_int_t timeout; | ||
1058 | compat_caddr_t reserved[1]; | ||
1059 | }; | ||
1060 | |||
1061 | static int cdrom_do_read_audio(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
1062 | { | ||
1063 | struct cdrom_read_audio __user *cdread_audio; | ||
1064 | struct cdrom_read_audio32 __user *cdread_audio32; | ||
1065 | __u32 data; | ||
1066 | void __user *datap; | ||
1067 | |||
1068 | cdread_audio = compat_alloc_user_space(sizeof(*cdread_audio)); | ||
1069 | cdread_audio32 = compat_ptr(arg); | ||
1070 | |||
1071 | if (copy_in_user(&cdread_audio->addr, | ||
1072 | &cdread_audio32->addr, | ||
1073 | (sizeof(*cdread_audio32) - | ||
1074 | sizeof(compat_caddr_t)))) | ||
1075 | return -EFAULT; | ||
1076 | |||
1077 | if (get_user(data, &cdread_audio32->buf)) | ||
1078 | return -EFAULT; | ||
1079 | datap = compat_ptr(data); | ||
1080 | if (put_user(datap, &cdread_audio->buf)) | ||
1081 | return -EFAULT; | ||
1082 | |||
1083 | return sys_ioctl(fd, cmd, (unsigned long) cdread_audio); | ||
1084 | } | ||
1085 | |||
1086 | static int cdrom_do_generic_command(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
1087 | { | ||
1088 | struct cdrom_generic_command __user *cgc; | ||
1089 | struct cdrom_generic_command32 __user *cgc32; | ||
1090 | u32 data; | ||
1091 | unsigned char dir; | ||
1092 | int itmp; | ||
1093 | |||
1094 | cgc = compat_alloc_user_space(sizeof(*cgc)); | ||
1095 | cgc32 = compat_ptr(arg); | ||
1096 | |||
1097 | if (copy_in_user(&cgc->cmd, &cgc32->cmd, sizeof(cgc->cmd)) || | ||
1098 | get_user(data, &cgc32->buffer) || | ||
1099 | put_user(compat_ptr(data), &cgc->buffer) || | ||
1100 | copy_in_user(&cgc->buflen, &cgc32->buflen, | ||
1101 | (sizeof(unsigned int) + sizeof(int))) || | ||
1102 | get_user(data, &cgc32->sense) || | ||
1103 | put_user(compat_ptr(data), &cgc->sense) || | ||
1104 | get_user(dir, &cgc32->data_direction) || | ||
1105 | put_user(dir, &cgc->data_direction) || | ||
1106 | get_user(itmp, &cgc32->quiet) || | ||
1107 | put_user(itmp, &cgc->quiet) || | ||
1108 | get_user(itmp, &cgc32->timeout) || | ||
1109 | put_user(itmp, &cgc->timeout) || | ||
1110 | get_user(data, &cgc32->reserved[0]) || | ||
1111 | put_user(compat_ptr(data), &cgc->reserved[0])) | ||
1112 | return -EFAULT; | ||
1113 | |||
1114 | return sys_ioctl(fd, cmd, (unsigned long) cgc); | ||
1115 | } | ||
1116 | |||
1117 | static int cdrom_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
1118 | { | ||
1119 | int err; | ||
1120 | |||
1121 | switch(cmd) { | ||
1122 | case CDROMREADAUDIO: | ||
1123 | err = cdrom_do_read_audio(fd, cmd, arg); | ||
1124 | break; | ||
1125 | |||
1126 | case CDROM_SEND_PACKET: | ||
1127 | err = cdrom_do_generic_command(fd, cmd, arg); | ||
1128 | break; | ||
1129 | |||
1130 | default: | ||
1131 | do { | ||
1132 | static int count; | ||
1133 | if (++count <= 20) | ||
1134 | printk("cdrom_ioctl: Unknown cmd fd(%d) " | ||
1135 | "cmd(%08x) arg(%08x)\n", | ||
1136 | (int)fd, (unsigned int)cmd, (unsigned int)arg); | ||
1137 | } while(0); | ||
1138 | err = -EINVAL; | ||
1139 | break; | ||
1140 | }; | ||
1141 | |||
1142 | return err; | ||
1143 | } | ||
1144 | #endif /* CONFIG_BLOCK */ | 1041 | #endif /* CONFIG_BLOCK */ |
1145 | 1042 | ||
1146 | #ifdef CONFIG_VT | 1043 | #ifdef CONFIG_VT |
@@ -3147,8 +3044,6 @@ HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) | |||
3147 | #ifdef CONFIG_BLOCK | 3044 | #ifdef CONFIG_BLOCK |
3148 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) | 3045 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) |
3149 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) | 3046 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) |
3150 | HANDLE_IOCTL(CDROMREADAUDIO, cdrom_ioctl_trans) | ||
3151 | HANDLE_IOCTL(CDROM_SEND_PACKET, cdrom_ioctl_trans) | ||
3152 | #endif | 3047 | #endif |
3153 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | 3048 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) |
3154 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) | 3049 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) |