diff options
Diffstat (limited to 'fs/compat_ioctl.c')
| -rw-r--r-- | fs/compat_ioctl.c | 1532 |
1 files changed, 204 insertions, 1328 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index d84e7058c298..14cbc831422a 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
| @@ -111,43 +111,40 @@ | |||
| 111 | #include <linux/dvb/frontend.h> | 111 | #include <linux/dvb/frontend.h> |
| 112 | #include <linux/dvb/video.h> | 112 | #include <linux/dvb/video.h> |
| 113 | 113 | ||
| 114 | #include <linux/sort.h> | ||
| 115 | |||
| 114 | #ifdef CONFIG_SPARC | 116 | #ifdef CONFIG_SPARC |
| 115 | #include <asm/fbio.h> | 117 | #include <asm/fbio.h> |
| 116 | #endif | 118 | #endif |
| 117 | 119 | ||
| 118 | static int do_ioctl32_pointer(unsigned int fd, unsigned int cmd, | 120 | static int w_long(unsigned int fd, unsigned int cmd, |
| 119 | unsigned long arg, struct file *f) | 121 | compat_ulong_t __user *argp) |
| 120 | { | ||
| 121 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); | ||
| 122 | } | ||
| 123 | |||
| 124 | static int w_long(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 125 | { | 122 | { |
| 126 | mm_segment_t old_fs = get_fs(); | 123 | mm_segment_t old_fs = get_fs(); |
| 127 | int err; | 124 | int err; |
| 128 | unsigned long val; | 125 | unsigned long val; |
| 129 | 126 | ||
| 130 | set_fs (KERNEL_DS); | 127 | set_fs (KERNEL_DS); |
| 131 | err = sys_ioctl(fd, cmd, (unsigned long)&val); | 128 | err = sys_ioctl(fd, cmd, (unsigned long)&val); |
| 132 | set_fs (old_fs); | 129 | set_fs (old_fs); |
| 133 | if (!err && put_user(val, (u32 __user *)compat_ptr(arg))) | 130 | if (!err && put_user(val, argp)) |
| 134 | return -EFAULT; | 131 | return -EFAULT; |
| 135 | return err; | 132 | return err; |
| 136 | } | 133 | } |
| 137 | 134 | ||
| 138 | static int rw_long(unsigned int fd, unsigned int cmd, unsigned long arg) | 135 | static int rw_long(unsigned int fd, unsigned int cmd, |
| 136 | compat_ulong_t __user *argp) | ||
| 139 | { | 137 | { |
| 140 | mm_segment_t old_fs = get_fs(); | 138 | mm_segment_t old_fs = get_fs(); |
| 141 | u32 __user *argptr = compat_ptr(arg); | ||
| 142 | int err; | 139 | int err; |
| 143 | unsigned long val; | 140 | unsigned long val; |
| 144 | 141 | ||
| 145 | if(get_user(val, argptr)) | 142 | if(get_user(val, argp)) |
| 146 | return -EFAULT; | 143 | return -EFAULT; |
| 147 | set_fs (KERNEL_DS); | 144 | set_fs (KERNEL_DS); |
| 148 | err = sys_ioctl(fd, cmd, (unsigned long)&val); | 145 | err = sys_ioctl(fd, cmd, (unsigned long)&val); |
| 149 | set_fs (old_fs); | 146 | set_fs (old_fs); |
| 150 | if (!err && put_user(val, argptr)) | 147 | if (!err && put_user(val, argp)) |
| 151 | return -EFAULT; | 148 | return -EFAULT; |
| 152 | return err; | 149 | return err; |
| 153 | } | 150 | } |
| @@ -161,7 +158,8 @@ struct compat_video_event { | |||
| 161 | } u; | 158 | } u; |
| 162 | }; | 159 | }; |
| 163 | 160 | ||
| 164 | static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long arg) | 161 | static int do_video_get_event(unsigned int fd, unsigned int cmd, |
| 162 | struct compat_video_event __user *up) | ||
| 165 | { | 163 | { |
| 166 | struct video_event kevent; | 164 | struct video_event kevent; |
| 167 | mm_segment_t old_fs = get_fs(); | 165 | mm_segment_t old_fs = get_fs(); |
| @@ -172,8 +170,6 @@ static int do_video_get_event(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 172 | set_fs(old_fs); | 170 | set_fs(old_fs); |
| 173 | 171 | ||
| 174 | if (!err) { | 172 | if (!err) { |
| 175 | struct compat_video_event __user *up = compat_ptr(arg); | ||
| 176 | |||
| 177 | err = put_user(kevent.type, &up->type); | 173 | err = put_user(kevent.type, &up->type); |
| 178 | err |= put_user(kevent.timestamp, &up->timestamp); | 174 | err |= put_user(kevent.timestamp, &up->timestamp); |
| 179 | err |= put_user(kevent.u.size.w, &up->u.size.w); | 175 | err |= put_user(kevent.u.size.w, &up->u.size.w); |
| @@ -192,15 +188,14 @@ struct compat_video_still_picture { | |||
| 192 | int32_t size; | 188 | int32_t size; |
| 193 | }; | 189 | }; |
| 194 | 190 | ||
| 195 | static int do_video_stillpicture(unsigned int fd, unsigned int cmd, unsigned long arg) | 191 | static int do_video_stillpicture(unsigned int fd, unsigned int cmd, |
| 192 | struct compat_video_still_picture __user *up) | ||
| 196 | { | 193 | { |
| 197 | struct compat_video_still_picture __user *up; | ||
| 198 | struct video_still_picture __user *up_native; | 194 | struct video_still_picture __user *up_native; |
| 199 | compat_uptr_t fp; | 195 | compat_uptr_t fp; |
| 200 | int32_t size; | 196 | int32_t size; |
| 201 | int err; | 197 | int err; |
| 202 | 198 | ||
| 203 | up = (struct compat_video_still_picture __user *) arg; | ||
| 204 | err = get_user(fp, &up->iFrame); | 199 | err = get_user(fp, &up->iFrame); |
| 205 | err |= get_user(size, &up->size); | 200 | err |= get_user(size, &up->size); |
| 206 | if (err) | 201 | if (err) |
| @@ -224,14 +219,13 @@ struct compat_video_spu_palette { | |||
| 224 | compat_uptr_t palette; | 219 | compat_uptr_t palette; |
| 225 | }; | 220 | }; |
| 226 | 221 | ||
| 227 | static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned long arg) | 222 | static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, |
| 223 | struct compat_video_spu_palette __user *up) | ||
| 228 | { | 224 | { |
| 229 | struct compat_video_spu_palette __user *up; | ||
| 230 | struct video_spu_palette __user *up_native; | 225 | struct video_spu_palette __user *up_native; |
| 231 | compat_uptr_t palp; | 226 | compat_uptr_t palp; |
| 232 | int length, err; | 227 | int length, err; |
| 233 | 228 | ||
| 234 | up = (struct compat_video_spu_palette __user *) arg; | ||
| 235 | err = get_user(palp, &up->palette); | 229 | err = get_user(palp, &up->palette); |
| 236 | err |= get_user(length, &up->length); | 230 | err |= get_user(length, &up->length); |
| 237 | 231 | ||
| @@ -246,428 +240,6 @@ static int do_video_set_spu_palette(unsigned int fd, unsigned int cmd, unsigned | |||
| 246 | return err; | 240 | return err; |
| 247 | } | 241 | } |
| 248 | 242 | ||
| 249 | #ifdef CONFIG_NET | ||
| 250 | static int do_siocgstamp(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 251 | { | ||
| 252 | struct compat_timeval __user *up = compat_ptr(arg); | ||
| 253 | struct timeval ktv; | ||
| 254 | mm_segment_t old_fs = get_fs(); | ||
| 255 | int err; | ||
| 256 | |||
| 257 | set_fs(KERNEL_DS); | ||
| 258 | err = sys_ioctl(fd, cmd, (unsigned long)&ktv); | ||
| 259 | set_fs(old_fs); | ||
| 260 | if(!err) { | ||
| 261 | err = put_user(ktv.tv_sec, &up->tv_sec); | ||
| 262 | err |= __put_user(ktv.tv_usec, &up->tv_usec); | ||
| 263 | } | ||
| 264 | return err; | ||
| 265 | } | ||
| 266 | |||
| 267 | static int do_siocgstampns(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 268 | { | ||
| 269 | struct compat_timespec __user *up = compat_ptr(arg); | ||
| 270 | struct timespec kts; | ||
| 271 | mm_segment_t old_fs = get_fs(); | ||
| 272 | int err; | ||
| 273 | |||
| 274 | set_fs(KERNEL_DS); | ||
| 275 | err = sys_ioctl(fd, cmd, (unsigned long)&kts); | ||
| 276 | set_fs(old_fs); | ||
| 277 | if (!err) { | ||
| 278 | err = put_user(kts.tv_sec, &up->tv_sec); | ||
| 279 | err |= __put_user(kts.tv_nsec, &up->tv_nsec); | ||
| 280 | } | ||
| 281 | return err; | ||
| 282 | } | ||
| 283 | |||
| 284 | struct ifmap32 { | ||
| 285 | compat_ulong_t mem_start; | ||
| 286 | compat_ulong_t mem_end; | ||
| 287 | unsigned short base_addr; | ||
| 288 | unsigned char irq; | ||
| 289 | unsigned char dma; | ||
| 290 | unsigned char port; | ||
| 291 | }; | ||
| 292 | |||
| 293 | struct ifreq32 { | ||
| 294 | #define IFHWADDRLEN 6 | ||
| 295 | #define IFNAMSIZ 16 | ||
| 296 | union { | ||
| 297 | char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ | ||
| 298 | } ifr_ifrn; | ||
| 299 | union { | ||
| 300 | struct sockaddr ifru_addr; | ||
| 301 | struct sockaddr ifru_dstaddr; | ||
| 302 | struct sockaddr ifru_broadaddr; | ||
| 303 | struct sockaddr ifru_netmask; | ||
| 304 | struct sockaddr ifru_hwaddr; | ||
| 305 | short ifru_flags; | ||
| 306 | compat_int_t ifru_ivalue; | ||
| 307 | compat_int_t ifru_mtu; | ||
| 308 | struct ifmap32 ifru_map; | ||
| 309 | char ifru_slave[IFNAMSIZ]; /* Just fits the size */ | ||
| 310 | char ifru_newname[IFNAMSIZ]; | ||
| 311 | compat_caddr_t ifru_data; | ||
| 312 | /* XXXX? ifru_settings should be here */ | ||
| 313 | } ifr_ifru; | ||
| 314 | }; | ||
| 315 | |||
| 316 | struct ifconf32 { | ||
| 317 | compat_int_t ifc_len; /* size of buffer */ | ||
| 318 | compat_caddr_t ifcbuf; | ||
| 319 | }; | ||
| 320 | |||
| 321 | static int dev_ifname32(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 322 | { | ||
| 323 | struct ifreq __user *uifr; | ||
| 324 | int err; | ||
| 325 | |||
| 326 | uifr = compat_alloc_user_space(sizeof(struct ifreq)); | ||
| 327 | if (copy_in_user(uifr, compat_ptr(arg), sizeof(struct ifreq32))) | ||
| 328 | return -EFAULT; | ||
| 329 | |||
| 330 | err = sys_ioctl(fd, SIOCGIFNAME, (unsigned long)uifr); | ||
| 331 | if (err) | ||
| 332 | return err; | ||
| 333 | |||
| 334 | if (copy_in_user(compat_ptr(arg), uifr, sizeof(struct ifreq32))) | ||
| 335 | return -EFAULT; | ||
| 336 | |||
| 337 | return 0; | ||
| 338 | } | ||
| 339 | |||
| 340 | static int dev_ifconf(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 341 | { | ||
| 342 | struct ifconf32 ifc32; | ||
| 343 | struct ifconf ifc; | ||
| 344 | struct ifconf __user *uifc; | ||
| 345 | struct ifreq32 __user *ifr32; | ||
| 346 | struct ifreq __user *ifr; | ||
| 347 | unsigned int i, j; | ||
| 348 | int err; | ||
| 349 | |||
| 350 | if (copy_from_user(&ifc32, compat_ptr(arg), sizeof(struct ifconf32))) | ||
| 351 | return -EFAULT; | ||
| 352 | |||
| 353 | if (ifc32.ifcbuf == 0) { | ||
| 354 | ifc32.ifc_len = 0; | ||
| 355 | ifc.ifc_len = 0; | ||
| 356 | ifc.ifc_req = NULL; | ||
| 357 | uifc = compat_alloc_user_space(sizeof(struct ifconf)); | ||
| 358 | } else { | ||
| 359 | size_t len =((ifc32.ifc_len / sizeof (struct ifreq32)) + 1) * | ||
| 360 | sizeof (struct ifreq); | ||
| 361 | uifc = compat_alloc_user_space(sizeof(struct ifconf) + len); | ||
| 362 | ifc.ifc_len = len; | ||
| 363 | ifr = ifc.ifc_req = (void __user *)(uifc + 1); | ||
| 364 | ifr32 = compat_ptr(ifc32.ifcbuf); | ||
| 365 | for (i = 0; i < ifc32.ifc_len; i += sizeof (struct ifreq32)) { | ||
| 366 | if (copy_in_user(ifr, ifr32, sizeof(struct ifreq32))) | ||
| 367 | return -EFAULT; | ||
| 368 | ifr++; | ||
| 369 | ifr32++; | ||
| 370 | } | ||
| 371 | } | ||
| 372 | if (copy_to_user(uifc, &ifc, sizeof(struct ifconf))) | ||
| 373 | return -EFAULT; | ||
| 374 | |||
| 375 | err = sys_ioctl (fd, SIOCGIFCONF, (unsigned long)uifc); | ||
| 376 | if (err) | ||
| 377 | return err; | ||
| 378 | |||
| 379 | if (copy_from_user(&ifc, uifc, sizeof(struct ifconf))) | ||
| 380 | return -EFAULT; | ||
| 381 | |||
| 382 | ifr = ifc.ifc_req; | ||
| 383 | ifr32 = compat_ptr(ifc32.ifcbuf); | ||
| 384 | for (i = 0, j = 0; | ||
| 385 | i + sizeof (struct ifreq32) <= ifc32.ifc_len && j < ifc.ifc_len; | ||
| 386 | i += sizeof (struct ifreq32), j += sizeof (struct ifreq)) { | ||
| 387 | if (copy_in_user(ifr32, ifr, sizeof (struct ifreq32))) | ||
| 388 | return -EFAULT; | ||
| 389 | ifr32++; | ||
| 390 | ifr++; | ||
| 391 | } | ||
| 392 | |||
| 393 | if (ifc32.ifcbuf == 0) { | ||
| 394 | /* Translate from 64-bit structure multiple to | ||
| 395 | * a 32-bit one. | ||
| 396 | */ | ||
| 397 | i = ifc.ifc_len; | ||
| 398 | i = ((i / sizeof(struct ifreq)) * sizeof(struct ifreq32)); | ||
| 399 | ifc32.ifc_len = i; | ||
| 400 | } else { | ||
| 401 | ifc32.ifc_len = i; | ||
| 402 | } | ||
| 403 | if (copy_to_user(compat_ptr(arg), &ifc32, sizeof(struct ifconf32))) | ||
| 404 | return -EFAULT; | ||
| 405 | |||
| 406 | return 0; | ||
| 407 | } | ||
| 408 | |||
| 409 | static int ethtool_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 410 | { | ||
| 411 | struct ifreq __user *ifr; | ||
| 412 | struct ifreq32 __user *ifr32; | ||
| 413 | u32 data; | ||
| 414 | void __user *datap; | ||
| 415 | |||
| 416 | ifr = compat_alloc_user_space(sizeof(*ifr)); | ||
| 417 | ifr32 = compat_ptr(arg); | ||
| 418 | |||
| 419 | if (copy_in_user(&ifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) | ||
| 420 | return -EFAULT; | ||
| 421 | |||
| 422 | if (get_user(data, &ifr32->ifr_ifru.ifru_data)) | ||
| 423 | return -EFAULT; | ||
| 424 | |||
| 425 | datap = compat_ptr(data); | ||
| 426 | if (put_user(datap, &ifr->ifr_ifru.ifru_data)) | ||
| 427 | return -EFAULT; | ||
| 428 | |||
| 429 | return sys_ioctl(fd, cmd, (unsigned long) ifr); | ||
| 430 | } | ||
| 431 | |||
| 432 | static int bond_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 433 | { | ||
| 434 | struct ifreq kifr; | ||
| 435 | struct ifreq __user *uifr; | ||
| 436 | struct ifreq32 __user *ifr32 = compat_ptr(arg); | ||
| 437 | mm_segment_t old_fs; | ||
| 438 | int err; | ||
| 439 | u32 data; | ||
| 440 | void __user *datap; | ||
| 441 | |||
| 442 | switch (cmd) { | ||
| 443 | case SIOCBONDENSLAVE: | ||
| 444 | case SIOCBONDRELEASE: | ||
| 445 | case SIOCBONDSETHWADDR: | ||
| 446 | case SIOCBONDCHANGEACTIVE: | ||
| 447 | if (copy_from_user(&kifr, ifr32, sizeof(struct ifreq32))) | ||
| 448 | return -EFAULT; | ||
| 449 | |||
| 450 | old_fs = get_fs(); | ||
| 451 | set_fs (KERNEL_DS); | ||
| 452 | err = sys_ioctl (fd, cmd, (unsigned long)&kifr); | ||
| 453 | set_fs (old_fs); | ||
| 454 | |||
| 455 | return err; | ||
| 456 | case SIOCBONDSLAVEINFOQUERY: | ||
| 457 | case SIOCBONDINFOQUERY: | ||
| 458 | uifr = compat_alloc_user_space(sizeof(*uifr)); | ||
| 459 | if (copy_in_user(&uifr->ifr_name, &ifr32->ifr_name, IFNAMSIZ)) | ||
| 460 | return -EFAULT; | ||
| 461 | |||
| 462 | if (get_user(data, &ifr32->ifr_ifru.ifru_data)) | ||
| 463 | return -EFAULT; | ||
| 464 | |||
| 465 | datap = compat_ptr(data); | ||
| 466 | if (put_user(datap, &uifr->ifr_ifru.ifru_data)) | ||
| 467 | return -EFAULT; | ||
| 468 | |||
| 469 | return sys_ioctl (fd, cmd, (unsigned long)uifr); | ||
| 470 | default: | ||
| 471 | return -EINVAL; | ||
| 472 | }; | ||
| 473 | } | ||
| 474 | |||
| 475 | static int siocdevprivate_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 476 | { | ||
| 477 | struct ifreq __user *u_ifreq64; | ||
| 478 | struct ifreq32 __user *u_ifreq32 = compat_ptr(arg); | ||
| 479 | char tmp_buf[IFNAMSIZ]; | ||
| 480 | void __user *data64; | ||
| 481 | u32 data32; | ||
| 482 | |||
| 483 | if (copy_from_user(&tmp_buf[0], &(u_ifreq32->ifr_ifrn.ifrn_name[0]), | ||
| 484 | IFNAMSIZ)) | ||
| 485 | return -EFAULT; | ||
| 486 | if (__get_user(data32, &u_ifreq32->ifr_ifru.ifru_data)) | ||
| 487 | return -EFAULT; | ||
| 488 | data64 = compat_ptr(data32); | ||
| 489 | |||
| 490 | u_ifreq64 = compat_alloc_user_space(sizeof(*u_ifreq64)); | ||
| 491 | |||
| 492 | /* Don't check these user accesses, just let that get trapped | ||
| 493 | * in the ioctl handler instead. | ||
| 494 | */ | ||
| 495 | if (copy_to_user(&u_ifreq64->ifr_ifrn.ifrn_name[0], &tmp_buf[0], | ||
| 496 | IFNAMSIZ)) | ||
| 497 | return -EFAULT; | ||
| 498 | if (__put_user(data64, &u_ifreq64->ifr_ifru.ifru_data)) | ||
| 499 | return -EFAULT; | ||
| 500 | |||
| 501 | return sys_ioctl(fd, cmd, (unsigned long) u_ifreq64); | ||
| 502 | } | ||
| 503 | |||
| 504 | static int dev_ifsioc(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 505 | { | ||
| 506 | struct ifreq ifr; | ||
| 507 | struct ifreq32 __user *uifr32; | ||
| 508 | struct ifmap32 __user *uifmap32; | ||
| 509 | mm_segment_t old_fs; | ||
| 510 | int err; | ||
| 511 | |||
| 512 | uifr32 = compat_ptr(arg); | ||
| 513 | uifmap32 = &uifr32->ifr_ifru.ifru_map; | ||
| 514 | switch (cmd) { | ||
| 515 | case SIOCSIFMAP: | ||
| 516 | err = copy_from_user(&ifr, uifr32, sizeof(ifr.ifr_name)); | ||
| 517 | err |= __get_user(ifr.ifr_map.mem_start, &uifmap32->mem_start); | ||
| 518 | err |= __get_user(ifr.ifr_map.mem_end, &uifmap32->mem_end); | ||
| 519 | err |= __get_user(ifr.ifr_map.base_addr, &uifmap32->base_addr); | ||
| 520 | err |= __get_user(ifr.ifr_map.irq, &uifmap32->irq); | ||
| 521 | err |= __get_user(ifr.ifr_map.dma, &uifmap32->dma); | ||
| 522 | err |= __get_user(ifr.ifr_map.port, &uifmap32->port); | ||
| 523 | if (err) | ||
| 524 | return -EFAULT; | ||
| 525 | break; | ||
| 526 | case SIOCSHWTSTAMP: | ||
| 527 | if (copy_from_user(&ifr, uifr32, sizeof(*uifr32))) | ||
| 528 | return -EFAULT; | ||
| 529 | ifr.ifr_data = compat_ptr(uifr32->ifr_ifru.ifru_data); | ||
| 530 | break; | ||
| 531 | default: | ||
| 532 | if (copy_from_user(&ifr, uifr32, sizeof(*uifr32))) | ||
| 533 | return -EFAULT; | ||
| 534 | break; | ||
| 535 | } | ||
| 536 | old_fs = get_fs(); | ||
| 537 | set_fs (KERNEL_DS); | ||
| 538 | err = sys_ioctl (fd, cmd, (unsigned long)&ifr); | ||
| 539 | set_fs (old_fs); | ||
| 540 | if (!err) { | ||
| 541 | switch (cmd) { | ||
| 542 | /* TUNSETIFF is defined as _IOW, it should be _IORW | ||
| 543 | * as the data is copied back to user space, but that | ||
| 544 | * cannot be fixed without breaking all existing apps. | ||
| 545 | */ | ||
| 546 | case TUNSETIFF: | ||
| 547 | case TUNGETIFF: | ||
| 548 | case SIOCGIFFLAGS: | ||
| 549 | case SIOCGIFMETRIC: | ||
| 550 | case SIOCGIFMTU: | ||
| 551 | case SIOCGIFMEM: | ||
| 552 | case SIOCGIFHWADDR: | ||
| 553 | case SIOCGIFINDEX: | ||
| 554 | case SIOCGIFADDR: | ||
| 555 | case SIOCGIFBRDADDR: | ||
| 556 | case SIOCGIFDSTADDR: | ||
| 557 | case SIOCGIFNETMASK: | ||
| 558 | case SIOCGIFTXQLEN: | ||
| 559 | if (copy_to_user(uifr32, &ifr, sizeof(*uifr32))) | ||
| 560 | return -EFAULT; | ||
| 561 | break; | ||
| 562 | case SIOCGIFMAP: | ||
| 563 | err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name)); | ||
| 564 | err |= __put_user(ifr.ifr_map.mem_start, &uifmap32->mem_start); | ||
| 565 | err |= __put_user(ifr.ifr_map.mem_end, &uifmap32->mem_end); | ||
| 566 | err |= __put_user(ifr.ifr_map.base_addr, &uifmap32->base_addr); | ||
| 567 | err |= __put_user(ifr.ifr_map.irq, &uifmap32->irq); | ||
| 568 | err |= __put_user(ifr.ifr_map.dma, &uifmap32->dma); | ||
| 569 | err |= __put_user(ifr.ifr_map.port, &uifmap32->port); | ||
| 570 | if (err) | ||
| 571 | err = -EFAULT; | ||
| 572 | break; | ||
| 573 | } | ||
| 574 | } | ||
| 575 | return err; | ||
| 576 | } | ||
| 577 | |||
| 578 | struct rtentry32 { | ||
| 579 | u32 rt_pad1; | ||
| 580 | struct sockaddr rt_dst; /* target address */ | ||
| 581 | struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */ | ||
| 582 | struct sockaddr rt_genmask; /* target network mask (IP) */ | ||
| 583 | unsigned short rt_flags; | ||
| 584 | short rt_pad2; | ||
| 585 | u32 rt_pad3; | ||
| 586 | unsigned char rt_tos; | ||
| 587 | unsigned char rt_class; | ||
| 588 | short rt_pad4; | ||
| 589 | short rt_metric; /* +1 for binary compatibility! */ | ||
| 590 | /* char * */ u32 rt_dev; /* forcing the device at add */ | ||
| 591 | u32 rt_mtu; /* per route MTU/Window */ | ||
| 592 | u32 rt_window; /* Window clamping */ | ||
| 593 | unsigned short rt_irtt; /* Initial RTT */ | ||
| 594 | |||
| 595 | }; | ||
| 596 | |||
| 597 | struct in6_rtmsg32 { | ||
| 598 | struct in6_addr rtmsg_dst; | ||
| 599 | struct in6_addr rtmsg_src; | ||
| 600 | struct in6_addr rtmsg_gateway; | ||
| 601 | u32 rtmsg_type; | ||
| 602 | u16 rtmsg_dst_len; | ||
| 603 | u16 rtmsg_src_len; | ||
| 604 | u32 rtmsg_metric; | ||
| 605 | u32 rtmsg_info; | ||
| 606 | u32 rtmsg_flags; | ||
| 607 | s32 rtmsg_ifindex; | ||
| 608 | }; | ||
| 609 | |||
| 610 | static int routing_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 611 | { | ||
| 612 | int ret; | ||
| 613 | void *r = NULL; | ||
| 614 | struct in6_rtmsg r6; | ||
| 615 | struct rtentry r4; | ||
| 616 | char devname[16]; | ||
| 617 | u32 rtdev; | ||
| 618 | mm_segment_t old_fs = get_fs(); | ||
| 619 | |||
| 620 | struct socket *mysock = sockfd_lookup(fd, &ret); | ||
| 621 | |||
| 622 | if (mysock && mysock->sk && mysock->sk->sk_family == AF_INET6) { /* ipv6 */ | ||
| 623 | struct in6_rtmsg32 __user *ur6 = compat_ptr(arg); | ||
| 624 | ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst), | ||
| 625 | 3 * sizeof(struct in6_addr)); | ||
| 626 | ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type)); | ||
| 627 | ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len)); | ||
| 628 | ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len)); | ||
| 629 | ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric)); | ||
| 630 | ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info)); | ||
| 631 | ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags)); | ||
| 632 | ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex)); | ||
| 633 | |||
| 634 | r = (void *) &r6; | ||
| 635 | } else { /* ipv4 */ | ||
| 636 | struct rtentry32 __user *ur4 = compat_ptr(arg); | ||
| 637 | ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst), | ||
| 638 | 3 * sizeof(struct sockaddr)); | ||
| 639 | ret |= __get_user (r4.rt_flags, &(ur4->rt_flags)); | ||
| 640 | ret |= __get_user (r4.rt_metric, &(ur4->rt_metric)); | ||
| 641 | ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu)); | ||
| 642 | ret |= __get_user (r4.rt_window, &(ur4->rt_window)); | ||
| 643 | ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt)); | ||
| 644 | ret |= __get_user (rtdev, &(ur4->rt_dev)); | ||
| 645 | if (rtdev) { | ||
| 646 | ret |= copy_from_user (devname, compat_ptr(rtdev), 15); | ||
| 647 | r4.rt_dev = devname; devname[15] = 0; | ||
| 648 | } else | ||
| 649 | r4.rt_dev = NULL; | ||
| 650 | |||
| 651 | r = (void *) &r4; | ||
| 652 | } | ||
| 653 | |||
| 654 | if (ret) { | ||
| 655 | ret = -EFAULT; | ||
| 656 | goto out; | ||
| 657 | } | ||
| 658 | |||
| 659 | set_fs (KERNEL_DS); | ||
| 660 | ret = sys_ioctl (fd, cmd, (unsigned long) r); | ||
| 661 | set_fs (old_fs); | ||
| 662 | |||
| 663 | out: | ||
| 664 | if (mysock) | ||
| 665 | sockfd_put(mysock); | ||
| 666 | |||
| 667 | return ret; | ||
| 668 | } | ||
| 669 | #endif | ||
| 670 | |||
| 671 | #ifdef CONFIG_BLOCK | 243 | #ifdef CONFIG_BLOCK |
| 672 | typedef struct sg_io_hdr32 { | 244 | typedef struct sg_io_hdr32 { |
| 673 | compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ | 245 | compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */ |
| @@ -721,16 +293,15 @@ static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iov | |||
| 721 | return 0; | 293 | return 0; |
| 722 | } | 294 | } |
| 723 | 295 | ||
| 724 | static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 296 | static int sg_ioctl_trans(unsigned int fd, unsigned int cmd, |
| 297 | sg_io_hdr32_t __user *sgio32) | ||
| 725 | { | 298 | { |
| 726 | sg_io_hdr_t __user *sgio; | 299 | sg_io_hdr_t __user *sgio; |
| 727 | sg_io_hdr32_t __user *sgio32; | ||
| 728 | u16 iovec_count; | 300 | u16 iovec_count; |
| 729 | u32 data; | 301 | u32 data; |
| 730 | void __user *dxferp; | 302 | void __user *dxferp; |
| 731 | int err; | 303 | int err; |
| 732 | 304 | ||
| 733 | sgio32 = compat_ptr(arg); | ||
| 734 | if (get_user(iovec_count, &sgio32->iovec_count)) | 305 | if (get_user(iovec_count, &sgio32->iovec_count)) |
| 735 | return -EFAULT; | 306 | return -EFAULT; |
| 736 | 307 | ||
| @@ -820,11 +391,11 @@ struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */ | |||
| 820 | int unused; | 391 | int unused; |
| 821 | }; | 392 | }; |
| 822 | 393 | ||
| 823 | static int sg_grt_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 394 | static int sg_grt_trans(unsigned int fd, unsigned int cmd, struct |
| 395 | compat_sg_req_info __user *o) | ||
| 824 | { | 396 | { |
| 825 | int err, i; | 397 | int err, i; |
| 826 | sg_req_info_t __user *r; | 398 | sg_req_info_t __user *r; |
| 827 | struct compat_sg_req_info __user *o = (void __user *)arg; | ||
| 828 | r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); | 399 | r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE); |
| 829 | err = sys_ioctl(fd,cmd,(unsigned long)r); | 400 | err = sys_ioctl(fd,cmd,(unsigned long)r); |
| 830 | if (err < 0) | 401 | if (err < 0) |
| @@ -852,9 +423,9 @@ struct sock_fprog32 { | |||
| 852 | #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) | 423 | #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32) |
| 853 | #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) | 424 | #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32) |
| 854 | 425 | ||
| 855 | static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 426 | static int ppp_sock_fprog_ioctl_trans(unsigned int fd, unsigned int cmd, |
| 427 | struct sock_fprog32 __user *u_fprog32) | ||
| 856 | { | 428 | { |
| 857 | struct sock_fprog32 __user *u_fprog32 = compat_ptr(arg); | ||
| 858 | struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); | 429 | struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog)); |
| 859 | void __user *fptr64; | 430 | void __user *fptr64; |
| 860 | u32 fptr32; | 431 | u32 fptr32; |
| @@ -891,15 +462,14 @@ struct ppp_idle32 { | |||
| 891 | }; | 462 | }; |
| 892 | #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) | 463 | #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32) |
| 893 | 464 | ||
| 894 | static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) | 465 | static int ppp_gidle(unsigned int fd, unsigned int cmd, |
| 466 | struct ppp_idle32 __user *idle32) | ||
| 895 | { | 467 | { |
| 896 | struct ppp_idle __user *idle; | 468 | struct ppp_idle __user *idle; |
| 897 | struct ppp_idle32 __user *idle32; | ||
| 898 | __kernel_time_t xmit, recv; | 469 | __kernel_time_t xmit, recv; |
| 899 | int err; | 470 | int err; |
| 900 | 471 | ||
| 901 | idle = compat_alloc_user_space(sizeof(*idle)); | 472 | idle = compat_alloc_user_space(sizeof(*idle)); |
| 902 | idle32 = compat_ptr(arg); | ||
| 903 | 473 | ||
| 904 | err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); | 474 | err = sys_ioctl(fd, PPPIOCGIDLE, (unsigned long) idle); |
| 905 | 475 | ||
| @@ -913,15 +483,14 @@ static int ppp_gidle(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 913 | return err; | 483 | return err; |
| 914 | } | 484 | } |
| 915 | 485 | ||
| 916 | static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) | 486 | static int ppp_scompress(unsigned int fd, unsigned int cmd, |
| 487 | struct ppp_option_data32 __user *odata32) | ||
| 917 | { | 488 | { |
| 918 | struct ppp_option_data __user *odata; | 489 | struct ppp_option_data __user *odata; |
| 919 | struct ppp_option_data32 __user *odata32; | ||
| 920 | __u32 data; | 490 | __u32 data; |
| 921 | void __user *datap; | 491 | void __user *datap; |
| 922 | 492 | ||
| 923 | odata = compat_alloc_user_space(sizeof(*odata)); | 493 | odata = compat_alloc_user_space(sizeof(*odata)); |
| 924 | odata32 = compat_ptr(arg); | ||
| 925 | 494 | ||
| 926 | if (get_user(data, &odata32->ptr)) | 495 | if (get_user(data, &odata32->ptr)) |
| 927 | return -EFAULT; | 496 | return -EFAULT; |
| @@ -937,35 +506,6 @@ static int ppp_scompress(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 937 | return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); | 506 | return sys_ioctl(fd, PPPIOCSCOMPRESS, (unsigned long) odata); |
| 938 | } | 507 | } |
| 939 | 508 | ||
| 940 | static int ppp_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 941 | { | ||
| 942 | int err; | ||
| 943 | |||
| 944 | switch (cmd) { | ||
| 945 | case PPPIOCGIDLE32: | ||
| 946 | err = ppp_gidle(fd, cmd, arg); | ||
| 947 | break; | ||
| 948 | |||
| 949 | case PPPIOCSCOMPRESS32: | ||
| 950 | err = ppp_scompress(fd, cmd, arg); | ||
| 951 | break; | ||
| 952 | |||
| 953 | default: | ||
| 954 | do { | ||
| 955 | static int count; | ||
| 956 | if (++count <= 20) | ||
| 957 | printk("ppp_ioctl: Unknown cmd fd(%d) " | ||
| 958 | "cmd(%08x) arg(%08x)\n", | ||
| 959 | (int)fd, (unsigned int)cmd, (unsigned int)arg); | ||
| 960 | } while(0); | ||
| 961 | err = -EINVAL; | ||
| 962 | break; | ||
| 963 | }; | ||
| 964 | |||
| 965 | return err; | ||
| 966 | } | ||
| 967 | |||
| 968 | |||
| 969 | #ifdef CONFIG_BLOCK | 509 | #ifdef CONFIG_BLOCK |
| 970 | struct mtget32 { | 510 | struct mtget32 { |
| 971 | compat_long_t mt_type; | 511 | compat_long_t mt_type; |
| @@ -983,7 +523,7 @@ struct mtpos32 { | |||
| 983 | }; | 523 | }; |
| 984 | #define MTIOCPOS32 _IOR('m', 3, struct mtpos32) | 524 | #define MTIOCPOS32 _IOR('m', 3, struct mtpos32) |
| 985 | 525 | ||
| 986 | static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | 526 | static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp) |
| 987 | { | 527 | { |
| 988 | mm_segment_t old_fs = get_fs(); | 528 | mm_segment_t old_fs = get_fs(); |
| 989 | struct mtget get; | 529 | struct mtget get; |
| @@ -1003,15 +543,6 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 1003 | kcmd = MTIOCGET; | 543 | kcmd = MTIOCGET; |
| 1004 | karg = &get; | 544 | karg = &get; |
| 1005 | break; | 545 | break; |
| 1006 | default: | ||
| 1007 | do { | ||
| 1008 | static int count; | ||
| 1009 | if (++count <= 20) | ||
| 1010 | printk("mt_ioctl: Unknown cmd fd(%d) " | ||
| 1011 | "cmd(%08x) arg(%08x)\n", | ||
| 1012 | (int)fd, (unsigned int)cmd, (unsigned int)arg); | ||
| 1013 | } while(0); | ||
| 1014 | return -EINVAL; | ||
| 1015 | } | 546 | } |
| 1016 | set_fs (KERNEL_DS); | 547 | set_fs (KERNEL_DS); |
| 1017 | err = sys_ioctl (fd, kcmd, (unsigned long)karg); | 548 | err = sys_ioctl (fd, kcmd, (unsigned long)karg); |
| @@ -1020,11 +551,11 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 1020 | return err; | 551 | return err; |
| 1021 | switch (cmd) { | 552 | switch (cmd) { |
| 1022 | case MTIOCPOS32: | 553 | case MTIOCPOS32: |
| 1023 | upos32 = compat_ptr(arg); | 554 | upos32 = argp; |
| 1024 | err = __put_user(pos.mt_blkno, &upos32->mt_blkno); | 555 | err = __put_user(pos.mt_blkno, &upos32->mt_blkno); |
| 1025 | break; | 556 | break; |
| 1026 | case MTIOCGET32: | 557 | case MTIOCGET32: |
| 1027 | umget32 = compat_ptr(arg); | 558 | umget32 = argp; |
| 1028 | err = __put_user(get.mt_type, &umget32->mt_type); | 559 | err = __put_user(get.mt_type, &umget32->mt_type); |
| 1029 | err |= __put_user(get.mt_resid, &umget32->mt_resid); | 560 | err |= __put_user(get.mt_resid, &umget32->mt_resid); |
| 1030 | err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); | 561 | err |= __put_user(get.mt_dsreg, &umget32->mt_dsreg); |
| @@ -1039,162 +570,8 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
| 1039 | 570 | ||
| 1040 | #endif /* CONFIG_BLOCK */ | 571 | #endif /* CONFIG_BLOCK */ |
| 1041 | 572 | ||
| 1042 | #ifdef CONFIG_VT | 573 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, |
| 1043 | 574 | compat_uid_t __user *argp) | |
| 1044 | static int vt_check(struct file *file) | ||
| 1045 | { | ||
| 1046 | struct tty_struct *tty; | ||
| 1047 | struct inode *inode = file->f_path.dentry->d_inode; | ||
| 1048 | struct vc_data *vc; | ||
| 1049 | |||
| 1050 | if (file->f_op->unlocked_ioctl != tty_ioctl) | ||
| 1051 | return -EINVAL; | ||
| 1052 | |||
| 1053 | tty = (struct tty_struct *)file->private_data; | ||
| 1054 | if (tty_paranoia_check(tty, inode, "tty_ioctl")) | ||
| 1055 | return -EINVAL; | ||
| 1056 | |||
| 1057 | if (tty->ops->ioctl != vt_ioctl) | ||
| 1058 | return -EINVAL; | ||
| 1059 | |||
| 1060 | vc = (struct vc_data *)tty->driver_data; | ||
| 1061 | if (!vc_cons_allocated(vc->vc_num)) /* impossible? */ | ||
| 1062 | return -ENOIOCTLCMD; | ||
| 1063 | |||
| 1064 | /* | ||
| 1065 | * To have permissions to do most of the vt ioctls, we either have | ||
| 1066 | * to be the owner of the tty, or have CAP_SYS_TTY_CONFIG. | ||
| 1067 | */ | ||
| 1068 | if (current->signal->tty == tty || capable(CAP_SYS_TTY_CONFIG)) | ||
| 1069 | return 1; | ||
| 1070 | return 0; | ||
| 1071 | } | ||
| 1072 | |||
| 1073 | struct consolefontdesc32 { | ||
| 1074 | unsigned short charcount; /* characters in font (256 or 512) */ | ||
| 1075 | unsigned short charheight; /* scan lines per character (1-32) */ | ||
| 1076 | compat_caddr_t chardata; /* font data in expanded form */ | ||
| 1077 | }; | ||
| 1078 | |||
| 1079 | static int do_fontx_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | ||
| 1080 | { | ||
| 1081 | struct consolefontdesc32 __user *user_cfd = compat_ptr(arg); | ||
| 1082 | struct console_font_op op; | ||
| 1083 | compat_caddr_t data; | ||
| 1084 | int i, perm; | ||
| 1085 | |||
| 1086 | perm = vt_check(file); | ||
| 1087 | if (perm < 0) return perm; | ||
| 1088 | |||
| 1089 | switch (cmd) { | ||
| 1090 | case PIO_FONTX: | ||
| 1091 | if (!perm) | ||
| 1092 | return -EPERM; | ||
| 1093 | op.op = KD_FONT_OP_SET; | ||
| 1094 | op.flags = 0; | ||
| 1095 | op.width = 8; | ||
| 1096 | if (get_user(op.height, &user_cfd->charheight) || | ||
| 1097 | get_user(op.charcount, &user_cfd->charcount) || | ||
| 1098 | get_user(data, &user_cfd->chardata)) | ||
| 1099 | return -EFAULT; | ||
| 1100 | op.data = compat_ptr(data); | ||
| 1101 | return con_font_op(vc_cons[fg_console].d, &op); | ||
| 1102 | case GIO_FONTX: | ||
| 1103 | op.op = KD_FONT_OP_GET; | ||
| 1104 | op.flags = 0; | ||
| 1105 | op.width = 8; | ||
| 1106 | if (get_user(op.height, &user_cfd->charheight) || | ||
| 1107 | get_user(op.charcount, &user_cfd->charcount) || | ||
| 1108 | get_user(data, &user_cfd->chardata)) | ||
| 1109 | return -EFAULT; | ||
| 1110 | if (!data) | ||
| 1111 | return 0; | ||
| 1112 | op.data = compat_ptr(data); | ||
| 1113 | i = con_font_op(vc_cons[fg_console].d, &op); | ||
| 1114 | if (i) | ||
| 1115 | return i; | ||
| 1116 | if (put_user(op.height, &user_cfd->charheight) || | ||
| 1117 | put_user(op.charcount, &user_cfd->charcount) || | ||
| 1118 | put_user((compat_caddr_t)(unsigned long)op.data, | ||
| 1119 | &user_cfd->chardata)) | ||
| 1120 | return -EFAULT; | ||
| 1121 | return 0; | ||
| 1122 | } | ||
| 1123 | return -EINVAL; | ||
| 1124 | } | ||
| 1125 | |||
| 1126 | struct console_font_op32 { | ||
| 1127 | compat_uint_t op; /* operation code KD_FONT_OP_* */ | ||
| 1128 | compat_uint_t flags; /* KD_FONT_FLAG_* */ | ||
| 1129 | compat_uint_t width, height; /* font size */ | ||
| 1130 | compat_uint_t charcount; | ||
| 1131 | compat_caddr_t data; /* font data with height fixed to 32 */ | ||
| 1132 | }; | ||
| 1133 | |||
| 1134 | static int do_kdfontop_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | ||
| 1135 | { | ||
| 1136 | struct console_font_op op; | ||
| 1137 | struct console_font_op32 __user *fontop = compat_ptr(arg); | ||
| 1138 | int perm = vt_check(file), i; | ||
| 1139 | struct vc_data *vc; | ||
| 1140 | |||
| 1141 | if (perm < 0) return perm; | ||
| 1142 | |||
| 1143 | if (copy_from_user(&op, fontop, sizeof(struct console_font_op32))) | ||
| 1144 | return -EFAULT; | ||
| 1145 | if (!perm && op.op != KD_FONT_OP_GET) | ||
| 1146 | return -EPERM; | ||
| 1147 | op.data = compat_ptr(((struct console_font_op32 *)&op)->data); | ||
| 1148 | op.flags |= KD_FONT_FLAG_OLD; | ||
| 1149 | vc = ((struct tty_struct *)file->private_data)->driver_data; | ||
| 1150 | i = con_font_op(vc, &op); | ||
| 1151 | if (i) | ||
| 1152 | return i; | ||
| 1153 | ((struct console_font_op32 *)&op)->data = (unsigned long)op.data; | ||
| 1154 | if (copy_to_user(fontop, &op, sizeof(struct console_font_op32))) | ||
| 1155 | return -EFAULT; | ||
| 1156 | return 0; | ||
| 1157 | } | ||
| 1158 | |||
| 1159 | struct unimapdesc32 { | ||
| 1160 | unsigned short entry_ct; | ||
| 1161 | compat_caddr_t entries; | ||
| 1162 | }; | ||
| 1163 | |||
| 1164 | static int do_unimap_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg, struct file *file) | ||
| 1165 | { | ||
| 1166 | struct unimapdesc32 tmp; | ||
| 1167 | struct unimapdesc32 __user *user_ud = compat_ptr(arg); | ||
| 1168 | int perm = vt_check(file); | ||
| 1169 | struct vc_data *vc; | ||
| 1170 | |||
| 1171 | if (perm < 0) | ||
| 1172 | return perm; | ||
| 1173 | if (copy_from_user(&tmp, user_ud, sizeof tmp)) | ||
| 1174 | return -EFAULT; | ||
| 1175 | if (tmp.entries) | ||
| 1176 | if (!access_ok(VERIFY_WRITE, compat_ptr(tmp.entries), | ||
| 1177 | tmp.entry_ct*sizeof(struct unipair))) | ||
| 1178 | return -EFAULT; | ||
| 1179 | vc = ((struct tty_struct *)file->private_data)->driver_data; | ||
| 1180 | switch (cmd) { | ||
| 1181 | case PIO_UNIMAP: | ||
| 1182 | if (!perm) | ||
| 1183 | return -EPERM; | ||
| 1184 | return con_set_unimap(vc, tmp.entry_ct, | ||
| 1185 | compat_ptr(tmp.entries)); | ||
| 1186 | case GIO_UNIMAP: | ||
| 1187 | if (!perm && fg_console != vc->vc_num) | ||
| 1188 | return -EPERM; | ||
| 1189 | return con_get_unimap(vc, tmp.entry_ct, &(user_ud->entry_ct), | ||
| 1190 | compat_ptr(tmp.entries)); | ||
| 1191 | } | ||
| 1192 | return 0; | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | #endif /* CONFIG_VT */ | ||
| 1196 | |||
| 1197 | static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1198 | { | 575 | { |
| 1199 | mm_segment_t old_fs = get_fs(); | 576 | mm_segment_t old_fs = get_fs(); |
| 1200 | __kernel_uid_t kuid; | 577 | __kernel_uid_t kuid; |
| @@ -1207,184 +584,15 @@ static int do_smb_getmountuid(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 1207 | set_fs(old_fs); | 584 | set_fs(old_fs); |
| 1208 | 585 | ||
| 1209 | if (err >= 0) | 586 | if (err >= 0) |
| 1210 | err = put_user(kuid, (compat_uid_t __user *)compat_ptr(arg)); | 587 | err = put_user(kuid, argp); |
| 1211 | 588 | ||
| 1212 | return err; | 589 | return err; |
| 1213 | } | 590 | } |
| 1214 | 591 | ||
| 1215 | struct atmif_sioc32 { | 592 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, |
| 1216 | compat_int_t number; | 593 | compat_ulong_t __user *argp) |
| 1217 | compat_int_t length; | ||
| 1218 | compat_caddr_t arg; | ||
| 1219 | }; | ||
| 1220 | |||
| 1221 | struct atm_iobuf32 { | ||
| 1222 | compat_int_t length; | ||
| 1223 | compat_caddr_t buffer; | ||
| 1224 | }; | ||
| 1225 | |||
| 1226 | #define ATM_GETLINKRATE32 _IOW('a', ATMIOC_ITF+1, struct atmif_sioc32) | ||
| 1227 | #define ATM_GETNAMES32 _IOW('a', ATMIOC_ITF+3, struct atm_iobuf32) | ||
| 1228 | #define ATM_GETTYPE32 _IOW('a', ATMIOC_ITF+4, struct atmif_sioc32) | ||
| 1229 | #define ATM_GETESI32 _IOW('a', ATMIOC_ITF+5, struct atmif_sioc32) | ||
| 1230 | #define ATM_GETADDR32 _IOW('a', ATMIOC_ITF+6, struct atmif_sioc32) | ||
| 1231 | #define ATM_RSTADDR32 _IOW('a', ATMIOC_ITF+7, struct atmif_sioc32) | ||
| 1232 | #define ATM_ADDADDR32 _IOW('a', ATMIOC_ITF+8, struct atmif_sioc32) | ||
| 1233 | #define ATM_DELADDR32 _IOW('a', ATMIOC_ITF+9, struct atmif_sioc32) | ||
| 1234 | #define ATM_GETCIRANGE32 _IOW('a', ATMIOC_ITF+10, struct atmif_sioc32) | ||
| 1235 | #define ATM_SETCIRANGE32 _IOW('a', ATMIOC_ITF+11, struct atmif_sioc32) | ||
| 1236 | #define ATM_SETESI32 _IOW('a', ATMIOC_ITF+12, struct atmif_sioc32) | ||
| 1237 | #define ATM_SETESIF32 _IOW('a', ATMIOC_ITF+13, struct atmif_sioc32) | ||
| 1238 | #define ATM_GETSTAT32 _IOW('a', ATMIOC_SARCOM+0, struct atmif_sioc32) | ||
| 1239 | #define ATM_GETSTATZ32 _IOW('a', ATMIOC_SARCOM+1, struct atmif_sioc32) | ||
| 1240 | #define ATM_GETLOOP32 _IOW('a', ATMIOC_SARCOM+2, struct atmif_sioc32) | ||
| 1241 | #define ATM_SETLOOP32 _IOW('a', ATMIOC_SARCOM+3, struct atmif_sioc32) | ||
| 1242 | #define ATM_QUERYLOOP32 _IOW('a', ATMIOC_SARCOM+4, struct atmif_sioc32) | ||
| 1243 | |||
| 1244 | static struct { | ||
| 1245 | unsigned int cmd32; | ||
| 1246 | unsigned int cmd; | ||
| 1247 | } atm_ioctl_map[] = { | ||
| 1248 | { ATM_GETLINKRATE32, ATM_GETLINKRATE }, | ||
| 1249 | { ATM_GETNAMES32, ATM_GETNAMES }, | ||
| 1250 | { ATM_GETTYPE32, ATM_GETTYPE }, | ||
| 1251 | { ATM_GETESI32, ATM_GETESI }, | ||
| 1252 | { ATM_GETADDR32, ATM_GETADDR }, | ||
| 1253 | { ATM_RSTADDR32, ATM_RSTADDR }, | ||
| 1254 | { ATM_ADDADDR32, ATM_ADDADDR }, | ||
| 1255 | { ATM_DELADDR32, ATM_DELADDR }, | ||
| 1256 | { ATM_GETCIRANGE32, ATM_GETCIRANGE }, | ||
| 1257 | { ATM_SETCIRANGE32, ATM_SETCIRANGE }, | ||
| 1258 | { ATM_SETESI32, ATM_SETESI }, | ||
| 1259 | { ATM_SETESIF32, ATM_SETESIF }, | ||
| 1260 | { ATM_GETSTAT32, ATM_GETSTAT }, | ||
| 1261 | { ATM_GETSTATZ32, ATM_GETSTATZ }, | ||
| 1262 | { ATM_GETLOOP32, ATM_GETLOOP }, | ||
| 1263 | { ATM_SETLOOP32, ATM_SETLOOP }, | ||
| 1264 | { ATM_QUERYLOOP32, ATM_QUERYLOOP } | ||
| 1265 | }; | ||
| 1266 | |||
| 1267 | #define NR_ATM_IOCTL ARRAY_SIZE(atm_ioctl_map) | ||
| 1268 | |||
| 1269 | static int do_atm_iobuf(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1270 | { | 594 | { |
| 1271 | struct atm_iobuf __user *iobuf; | 595 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, argp); |
| 1272 | struct atm_iobuf32 __user *iobuf32; | ||
| 1273 | u32 data; | ||
| 1274 | void __user *datap; | ||
| 1275 | int len, err; | ||
| 1276 | |||
| 1277 | iobuf = compat_alloc_user_space(sizeof(*iobuf)); | ||
| 1278 | iobuf32 = compat_ptr(arg); | ||
| 1279 | |||
| 1280 | if (get_user(len, &iobuf32->length) || | ||
| 1281 | get_user(data, &iobuf32->buffer)) | ||
| 1282 | return -EFAULT; | ||
| 1283 | datap = compat_ptr(data); | ||
| 1284 | if (put_user(len, &iobuf->length) || | ||
| 1285 | put_user(datap, &iobuf->buffer)) | ||
| 1286 | return -EFAULT; | ||
| 1287 | |||
| 1288 | err = sys_ioctl(fd, cmd, (unsigned long)iobuf); | ||
| 1289 | |||
| 1290 | if (!err) { | ||
| 1291 | if (copy_in_user(&iobuf32->length, &iobuf->length, | ||
| 1292 | sizeof(int))) | ||
| 1293 | err = -EFAULT; | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | return err; | ||
| 1297 | } | ||
| 1298 | |||
| 1299 | static int do_atmif_sioc(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1300 | { | ||
| 1301 | struct atmif_sioc __user *sioc; | ||
| 1302 | struct atmif_sioc32 __user *sioc32; | ||
| 1303 | u32 data; | ||
| 1304 | void __user *datap; | ||
| 1305 | int err; | ||
| 1306 | |||
| 1307 | sioc = compat_alloc_user_space(sizeof(*sioc)); | ||
| 1308 | sioc32 = compat_ptr(arg); | ||
| 1309 | |||
| 1310 | if (copy_in_user(&sioc->number, &sioc32->number, 2 * sizeof(int)) || | ||
| 1311 | get_user(data, &sioc32->arg)) | ||
| 1312 | return -EFAULT; | ||
| 1313 | datap = compat_ptr(data); | ||
| 1314 | if (put_user(datap, &sioc->arg)) | ||
| 1315 | return -EFAULT; | ||
| 1316 | |||
| 1317 | err = sys_ioctl(fd, cmd, (unsigned long) sioc); | ||
| 1318 | |||
| 1319 | if (!err) { | ||
| 1320 | if (copy_in_user(&sioc32->length, &sioc->length, | ||
| 1321 | sizeof(int))) | ||
| 1322 | err = -EFAULT; | ||
| 1323 | } | ||
| 1324 | return err; | ||
| 1325 | } | ||
| 1326 | |||
| 1327 | static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg) | ||
| 1328 | { | ||
| 1329 | int i; | ||
| 1330 | unsigned int cmd = 0; | ||
| 1331 | |||
| 1332 | switch (cmd32) { | ||
| 1333 | case SONET_GETSTAT: | ||
| 1334 | case SONET_GETSTATZ: | ||
| 1335 | case SONET_GETDIAG: | ||
| 1336 | case SONET_SETDIAG: | ||
| 1337 | case SONET_CLRDIAG: | ||
| 1338 | case SONET_SETFRAMING: | ||
| 1339 | case SONET_GETFRAMING: | ||
| 1340 | case SONET_GETFRSENSE: | ||
| 1341 | return do_atmif_sioc(fd, cmd32, arg); | ||
| 1342 | } | ||
| 1343 | |||
| 1344 | for (i = 0; i < NR_ATM_IOCTL; i++) { | ||
| 1345 | if (cmd32 == atm_ioctl_map[i].cmd32) { | ||
| 1346 | cmd = atm_ioctl_map[i].cmd; | ||
| 1347 | break; | ||
| 1348 | } | ||
| 1349 | } | ||
| 1350 | if (i == NR_ATM_IOCTL) | ||
| 1351 | return -EINVAL; | ||
| 1352 | |||
| 1353 | switch (cmd) { | ||
| 1354 | case ATM_GETNAMES: | ||
| 1355 | return do_atm_iobuf(fd, cmd, arg); | ||
| 1356 | |||
| 1357 | case ATM_GETLINKRATE: | ||
| 1358 | case ATM_GETTYPE: | ||
| 1359 | case ATM_GETESI: | ||
| 1360 | case ATM_GETADDR: | ||
| 1361 | case ATM_RSTADDR: | ||
| 1362 | case ATM_ADDADDR: | ||
| 1363 | case ATM_DELADDR: | ||
| 1364 | case ATM_GETCIRANGE: | ||
| 1365 | case ATM_SETCIRANGE: | ||
| 1366 | case ATM_SETESI: | ||
| 1367 | case ATM_SETESIF: | ||
| 1368 | case ATM_GETSTAT: | ||
| 1369 | case ATM_GETSTATZ: | ||
| 1370 | case ATM_GETLOOP: | ||
| 1371 | case ATM_SETLOOP: | ||
| 1372 | case ATM_QUERYLOOP: | ||
| 1373 | return do_atmif_sioc(fd, cmd, arg); | ||
| 1374 | } | ||
| 1375 | |||
| 1376 | return -EINVAL; | ||
| 1377 | } | ||
| 1378 | |||
| 1379 | static __used int | ||
| 1380 | ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1381 | { | ||
| 1382 | return -EINVAL; | ||
| 1383 | } | ||
| 1384 | |||
| 1385 | static int ioc_settimeout(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1386 | { | ||
| 1387 | return rw_long(fd, AUTOFS_IOC_SETTIMEOUT, arg); | ||
| 1388 | } | 596 | } |
| 1389 | 597 | ||
| 1390 | /* Bluetooth ioctls */ | 598 | /* Bluetooth ioctls */ |
| @@ -1442,7 +650,8 @@ static int set_raw32_request(struct raw_config_request *req, struct raw32_config | |||
| 1442 | return ret ? -EFAULT : 0; | 650 | return ret ? -EFAULT : 0; |
| 1443 | } | 651 | } |
| 1444 | 652 | ||
| 1445 | static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 653 | static int raw_ioctl(unsigned fd, unsigned cmd, |
| 654 | struct raw32_config_request __user *user_req) | ||
| 1446 | { | 655 | { |
| 1447 | int ret; | 656 | int ret; |
| 1448 | 657 | ||
| @@ -1450,7 +659,6 @@ static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 1450 | case RAW_SETBIND: | 659 | case RAW_SETBIND: |
| 1451 | case RAW_GETBIND: { | 660 | case RAW_GETBIND: { |
| 1452 | struct raw_config_request req; | 661 | struct raw_config_request req; |
| 1453 | struct raw32_config_request __user *user_req = compat_ptr(arg); | ||
| 1454 | mm_segment_t oldfs = get_fs(); | 662 | mm_segment_t oldfs = get_fs(); |
| 1455 | 663 | ||
| 1456 | if ((ret = get_raw32_request(&req, user_req))) | 664 | if ((ret = get_raw32_request(&req, user_req))) |
| @@ -1465,9 +673,6 @@ static int raw_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 1465 | } | 673 | } |
| 1466 | break; | 674 | break; |
| 1467 | } | 675 | } |
| 1468 | default: | ||
| 1469 | ret = sys_ioctl(fd, cmd, arg); | ||
| 1470 | break; | ||
| 1471 | } | 676 | } |
| 1472 | return ret; | 677 | return ret; |
| 1473 | } | 678 | } |
| @@ -1495,11 +700,11 @@ struct serial_struct32 { | |||
| 1495 | compat_int_t reserved[1]; | 700 | compat_int_t reserved[1]; |
| 1496 | }; | 701 | }; |
| 1497 | 702 | ||
| 1498 | static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 703 | static int serial_struct_ioctl(unsigned fd, unsigned cmd, |
| 704 | struct serial_struct32 __user *ss32) | ||
| 1499 | { | 705 | { |
| 1500 | typedef struct serial_struct SS; | 706 | typedef struct serial_struct SS; |
| 1501 | typedef struct serial_struct32 SS32; | 707 | typedef struct serial_struct32 SS32; |
| 1502 | struct serial_struct32 __user *ss32 = compat_ptr(arg); | ||
| 1503 | int err; | 708 | int err; |
| 1504 | struct serial_struct ss; | 709 | struct serial_struct ss; |
| 1505 | mm_segment_t oldseg = get_fs(); | 710 | mm_segment_t oldseg = get_fs(); |
| @@ -1537,96 +742,6 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 1537 | return err; | 742 | return err; |
| 1538 | } | 743 | } |
| 1539 | 744 | ||
| 1540 | struct usbdevfs_ctrltransfer32 { | ||
| 1541 | u8 bRequestType; | ||
| 1542 | u8 bRequest; | ||
| 1543 | u16 wValue; | ||
| 1544 | u16 wIndex; | ||
| 1545 | u16 wLength; | ||
| 1546 | u32 timeout; /* in milliseconds */ | ||
| 1547 | compat_caddr_t data; | ||
| 1548 | }; | ||
| 1549 | |||
| 1550 | #define USBDEVFS_CONTROL32 _IOWR('U', 0, struct usbdevfs_ctrltransfer32) | ||
| 1551 | |||
| 1552 | static int do_usbdevfs_control(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1553 | { | ||
| 1554 | struct usbdevfs_ctrltransfer32 __user *p32 = compat_ptr(arg); | ||
| 1555 | struct usbdevfs_ctrltransfer __user *p; | ||
| 1556 | __u32 udata; | ||
| 1557 | p = compat_alloc_user_space(sizeof(*p)); | ||
| 1558 | if (copy_in_user(p, p32, (sizeof(*p32) - sizeof(compat_caddr_t))) || | ||
| 1559 | get_user(udata, &p32->data) || | ||
| 1560 | put_user(compat_ptr(udata), &p->data)) | ||
| 1561 | return -EFAULT; | ||
| 1562 | return sys_ioctl(fd, USBDEVFS_CONTROL, (unsigned long)p); | ||
| 1563 | } | ||
| 1564 | |||
| 1565 | |||
| 1566 | struct usbdevfs_bulktransfer32 { | ||
| 1567 | compat_uint_t ep; | ||
| 1568 | compat_uint_t len; | ||
| 1569 | compat_uint_t timeout; /* in milliseconds */ | ||
| 1570 | compat_caddr_t data; | ||
| 1571 | }; | ||
| 1572 | |||
| 1573 | #define USBDEVFS_BULK32 _IOWR('U', 2, struct usbdevfs_bulktransfer32) | ||
| 1574 | |||
| 1575 | static int do_usbdevfs_bulk(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1576 | { | ||
| 1577 | struct usbdevfs_bulktransfer32 __user *p32 = compat_ptr(arg); | ||
| 1578 | struct usbdevfs_bulktransfer __user *p; | ||
| 1579 | compat_uint_t n; | ||
| 1580 | compat_caddr_t addr; | ||
| 1581 | |||
| 1582 | p = compat_alloc_user_space(sizeof(*p)); | ||
| 1583 | |||
| 1584 | if (get_user(n, &p32->ep) || put_user(n, &p->ep) || | ||
| 1585 | get_user(n, &p32->len) || put_user(n, &p->len) || | ||
| 1586 | get_user(n, &p32->timeout) || put_user(n, &p->timeout) || | ||
| 1587 | get_user(addr, &p32->data) || put_user(compat_ptr(addr), &p->data)) | ||
| 1588 | return -EFAULT; | ||
| 1589 | |||
| 1590 | return sys_ioctl(fd, USBDEVFS_BULK, (unsigned long)p); | ||
| 1591 | } | ||
| 1592 | |||
| 1593 | |||
| 1594 | /* | ||
| 1595 | * USBDEVFS_SUBMITURB, USBDEVFS_REAPURB and USBDEVFS_REAPURBNDELAY | ||
| 1596 | * are handled in usbdevfs core. -Christopher Li | ||
| 1597 | */ | ||
| 1598 | |||
| 1599 | struct usbdevfs_disconnectsignal32 { | ||
| 1600 | compat_int_t signr; | ||
| 1601 | compat_caddr_t context; | ||
| 1602 | }; | ||
| 1603 | |||
| 1604 | #define USBDEVFS_DISCSIGNAL32 _IOR('U', 14, struct usbdevfs_disconnectsignal32) | ||
| 1605 | |||
| 1606 | static int do_usbdevfs_discsignal(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1607 | { | ||
| 1608 | struct usbdevfs_disconnectsignal kdis; | ||
| 1609 | struct usbdevfs_disconnectsignal32 __user *udis; | ||
| 1610 | mm_segment_t old_fs; | ||
| 1611 | u32 uctx; | ||
| 1612 | int err; | ||
| 1613 | |||
| 1614 | udis = compat_ptr(arg); | ||
| 1615 | |||
| 1616 | if (get_user(kdis.signr, &udis->signr) || | ||
| 1617 | __get_user(uctx, &udis->context)) | ||
| 1618 | return -EFAULT; | ||
| 1619 | |||
| 1620 | kdis.context = compat_ptr(uctx); | ||
| 1621 | |||
| 1622 | old_fs = get_fs(); | ||
| 1623 | set_fs(KERNEL_DS); | ||
| 1624 | err = sys_ioctl(fd, USBDEVFS_DISCSIGNAL, (unsigned long) &kdis); | ||
| 1625 | set_fs(old_fs); | ||
| 1626 | |||
| 1627 | return err; | ||
| 1628 | } | ||
| 1629 | |||
| 1630 | /* | 745 | /* |
| 1631 | * I2C layer ioctls | 746 | * I2C layer ioctls |
| 1632 | */ | 747 | */ |
| @@ -1655,9 +770,9 @@ struct i2c_rdwr_aligned { | |||
| 1655 | struct i2c_msg msgs[0]; | 770 | struct i2c_msg msgs[0]; |
| 1656 | }; | 771 | }; |
| 1657 | 772 | ||
| 1658 | static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 773 | static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, |
| 774 | struct i2c_rdwr_ioctl_data32 __user *udata) | ||
| 1659 | { | 775 | { |
| 1660 | struct i2c_rdwr_ioctl_data32 __user *udata = compat_ptr(arg); | ||
| 1661 | struct i2c_rdwr_aligned __user *tdata; | 776 | struct i2c_rdwr_aligned __user *tdata; |
| 1662 | struct i2c_msg __user *tmsgs; | 777 | struct i2c_msg __user *tmsgs; |
| 1663 | struct i2c_msg32 __user *umsgs; | 778 | struct i2c_msg32 __user *umsgs; |
| @@ -1691,10 +806,10 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd, unsigned long ar | |||
| 1691 | return sys_ioctl(fd, cmd, (unsigned long)tdata); | 806 | return sys_ioctl(fd, cmd, (unsigned long)tdata); |
| 1692 | } | 807 | } |
| 1693 | 808 | ||
| 1694 | static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | 809 | static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, |
| 810 | struct i2c_smbus_ioctl_data32 __user *udata) | ||
| 1695 | { | 811 | { |
| 1696 | struct i2c_smbus_ioctl_data __user *tdata; | 812 | struct i2c_smbus_ioctl_data __user *tdata; |
| 1697 | struct i2c_smbus_ioctl_data32 __user *udata; | ||
| 1698 | compat_caddr_t datap; | 813 | compat_caddr_t datap; |
| 1699 | 814 | ||
| 1700 | tdata = compat_alloc_user_space(sizeof(*tdata)); | 815 | tdata = compat_alloc_user_space(sizeof(*tdata)); |
| @@ -1703,7 +818,6 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 1703 | if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata))) | 818 | if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata))) |
| 1704 | return -EFAULT; | 819 | return -EFAULT; |
| 1705 | 820 | ||
| 1706 | udata = compat_ptr(arg); | ||
| 1707 | if (!access_ok(VERIFY_READ, udata, sizeof(*udata))) | 821 | if (!access_ok(VERIFY_READ, udata, sizeof(*udata))) |
| 1708 | return -EFAULT; | 822 | return -EFAULT; |
| 1709 | 823 | ||
| @@ -1718,27 +832,12 @@ static int do_i2c_smbus_ioctl(unsigned int fd, unsigned int cmd, unsigned long a | |||
| 1718 | return sys_ioctl(fd, cmd, (unsigned long)tdata); | 832 | return sys_ioctl(fd, cmd, (unsigned long)tdata); |
| 1719 | } | 833 | } |
| 1720 | 834 | ||
| 1721 | /* Since old style bridge ioctl's endup using SIOCDEVPRIVATE | ||
| 1722 | * for some operations; this forces use of the newer bridge-utils that | ||
| 1723 | * use compatible ioctls | ||
| 1724 | */ | ||
| 1725 | static int old_bridge_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1726 | { | ||
| 1727 | u32 tmp; | ||
| 1728 | |||
| 1729 | if (get_user(tmp, (u32 __user *) arg)) | ||
| 1730 | return -EFAULT; | ||
| 1731 | if (tmp == BRCTL_GET_VERSION) | ||
| 1732 | return BRCTL_VERSION + 1; | ||
| 1733 | return -EINVAL; | ||
| 1734 | } | ||
| 1735 | |||
| 1736 | #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) | 835 | #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t) |
| 1737 | #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) | 836 | #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t) |
| 1738 | #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) | 837 | #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t) |
| 1739 | #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) | 838 | #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t) |
| 1740 | 839 | ||
| 1741 | static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | 840 | static int rtc_ioctl(unsigned fd, unsigned cmd, void __user *argp) |
| 1742 | { | 841 | { |
| 1743 | mm_segment_t oldfs = get_fs(); | 842 | mm_segment_t oldfs = get_fs(); |
| 1744 | compat_ulong_t val32; | 843 | compat_ulong_t val32; |
| @@ -1756,29 +855,14 @@ static int rtc_ioctl(unsigned fd, unsigned cmd, unsigned long arg) | |||
| 1756 | if (ret) | 855 | if (ret) |
| 1757 | return ret; | 856 | return ret; |
| 1758 | val32 = kval; | 857 | val32 = kval; |
| 1759 | return put_user(val32, (unsigned int __user *)arg); | 858 | return put_user(val32, (unsigned int __user *)argp); |
| 1760 | case RTC_IRQP_SET32: | 859 | case RTC_IRQP_SET32: |
| 1761 | return sys_ioctl(fd, RTC_IRQP_SET, arg); | 860 | return sys_ioctl(fd, RTC_IRQP_SET, (unsigned long)argp); |
| 1762 | case RTC_EPOCH_SET32: | 861 | case RTC_EPOCH_SET32: |
| 1763 | return sys_ioctl(fd, RTC_EPOCH_SET, arg); | 862 | return sys_ioctl(fd, RTC_EPOCH_SET, (unsigned long)argp); |
| 1764 | default: | ||
| 1765 | /* unreached */ | ||
| 1766 | return -ENOIOCTLCMD; | ||
| 1767 | } | 863 | } |
| 1768 | } | ||
| 1769 | 864 | ||
| 1770 | static int | 865 | return -ENOIOCTLCMD; |
| 1771 | lp_timeout_trans(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
| 1772 | { | ||
| 1773 | struct compat_timeval __user *tc = (struct compat_timeval __user *)arg; | ||
| 1774 | struct timeval __user *tn = compat_alloc_user_space(sizeof(struct timeval)); | ||
| 1775 | struct timeval ts; | ||
| 1776 | if (get_user(ts.tv_sec, &tc->tv_sec) || | ||
| 1777 | get_user(ts.tv_usec, &tc->tv_usec) || | ||
| 1778 | put_user(ts.tv_sec, &tn->tv_sec) || | ||
| 1779 | put_user(ts.tv_usec, &tn->tv_usec)) | ||
| 1780 | return -EFAULT; | ||
| 1781 | return sys_ioctl(fd, cmd, (unsigned long)tn); | ||
| 1782 | } | 866 | } |
| 1783 | 867 | ||
| 1784 | /* on ia32 l_start is on a 32-bit boundary */ | 868 | /* on ia32 l_start is on a 32-bit boundary */ |
| @@ -1798,9 +882,9 @@ struct space_resv_32 { | |||
| 1798 | #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) | 882 | #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32) |
| 1799 | 883 | ||
| 1800 | /* just account for different alignment */ | 884 | /* just account for different alignment */ |
| 1801 | static int compat_ioctl_preallocate(struct file *file, unsigned long arg) | 885 | static int compat_ioctl_preallocate(struct file *file, |
| 886 | struct space_resv_32 __user *p32) | ||
| 1802 | { | 887 | { |
| 1803 | struct space_resv_32 __user *p32 = compat_ptr(arg); | ||
| 1804 | struct space_resv __user *p = compat_alloc_user_space(sizeof(*p)); | 888 | struct space_resv __user *p = compat_alloc_user_space(sizeof(*p)); |
| 1805 | 889 | ||
| 1806 | if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) || | 890 | if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) || |
| @@ -1816,27 +900,13 @@ static int compat_ioctl_preallocate(struct file *file, unsigned long arg) | |||
| 1816 | } | 900 | } |
| 1817 | #endif | 901 | #endif |
| 1818 | 902 | ||
| 903 | /* | ||
| 904 | * simple reversible transform to make our table more evenly | ||
| 905 | * distributed after sorting. | ||
| 906 | */ | ||
| 907 | #define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0xffffffff) | ||
| 1819 | 908 | ||
| 1820 | typedef int (*ioctl_trans_handler_t)(unsigned int, unsigned int, | 909 | #define COMPATIBLE_IOCTL(cmd) XFORM(cmd), |
| 1821 | unsigned long, struct file *); | ||
| 1822 | |||
| 1823 | struct ioctl_trans { | ||
| 1824 | unsigned long cmd; | ||
| 1825 | ioctl_trans_handler_t handler; | ||
| 1826 | struct ioctl_trans *next; | ||
| 1827 | }; | ||
| 1828 | |||
| 1829 | #define HANDLE_IOCTL(cmd,handler) \ | ||
| 1830 | { (cmd), (ioctl_trans_handler_t)(handler) }, | ||
| 1831 | |||
| 1832 | /* pointer to compatible structure or no argument */ | ||
| 1833 | #define COMPATIBLE_IOCTL(cmd) \ | ||
| 1834 | { (cmd), do_ioctl32_pointer }, | ||
| 1835 | |||
| 1836 | /* argument is an unsigned long integer, not a pointer */ | ||
| 1837 | #define ULONG_IOCTL(cmd) \ | ||
| 1838 | { (cmd), (ioctl_trans_handler_t)sys_ioctl }, | ||
| 1839 | |||
| 1840 | /* ioctl should not be warned about even if it's not implemented. | 910 | /* ioctl should not be warned about even if it's not implemented. |
| 1841 | Valid reasons to use this: | 911 | Valid reasons to use this: |
| 1842 | - It is implemented with ->compat_ioctl on some device, but programs | 912 | - It is implemented with ->compat_ioctl on some device, but programs |
| @@ -1846,7 +916,7 @@ struct ioctl_trans { | |||
| 1846 | Most other reasons are not valid. */ | 916 | Most other reasons are not valid. */ |
| 1847 | #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd) | 917 | #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd) |
| 1848 | 918 | ||
| 1849 | static struct ioctl_trans ioctl_start[] = { | 919 | static unsigned int ioctl_pointer[] = { |
| 1850 | /* compatible ioctls first */ | 920 | /* compatible ioctls first */ |
| 1851 | COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */ | 921 | COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */ |
| 1852 | COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ | 922 | COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */ |
| @@ -1857,7 +927,6 @@ COMPATIBLE_IOCTL(TCSETA) | |||
| 1857 | COMPATIBLE_IOCTL(TCSETAW) | 927 | COMPATIBLE_IOCTL(TCSETAW) |
| 1858 | COMPATIBLE_IOCTL(TCSETAF) | 928 | COMPATIBLE_IOCTL(TCSETAF) |
| 1859 | COMPATIBLE_IOCTL(TCSBRK) | 929 | COMPATIBLE_IOCTL(TCSBRK) |
| 1860 | ULONG_IOCTL(TCSBRKP) | ||
| 1861 | COMPATIBLE_IOCTL(TCXONC) | 930 | COMPATIBLE_IOCTL(TCXONC) |
| 1862 | COMPATIBLE_IOCTL(TCFLSH) | 931 | COMPATIBLE_IOCTL(TCFLSH) |
| 1863 | COMPATIBLE_IOCTL(TCGETS) | 932 | COMPATIBLE_IOCTL(TCGETS) |
| @@ -1867,7 +936,6 @@ COMPATIBLE_IOCTL(TCSETSF) | |||
| 1867 | COMPATIBLE_IOCTL(TIOCLINUX) | 936 | COMPATIBLE_IOCTL(TIOCLINUX) |
| 1868 | COMPATIBLE_IOCTL(TIOCSBRK) | 937 | COMPATIBLE_IOCTL(TIOCSBRK) |
| 1869 | COMPATIBLE_IOCTL(TIOCCBRK) | 938 | COMPATIBLE_IOCTL(TIOCCBRK) |
| 1870 | ULONG_IOCTL(TIOCMIWAIT) | ||
| 1871 | COMPATIBLE_IOCTL(TIOCGICOUNT) | 939 | COMPATIBLE_IOCTL(TIOCGICOUNT) |
| 1872 | /* Little t */ | 940 | /* Little t */ |
| 1873 | COMPATIBLE_IOCTL(TIOCGETD) | 941 | COMPATIBLE_IOCTL(TIOCGETD) |
| @@ -1889,7 +957,6 @@ COMPATIBLE_IOCTL(TIOCSTI) | |||
| 1889 | COMPATIBLE_IOCTL(TIOCOUTQ) | 957 | COMPATIBLE_IOCTL(TIOCOUTQ) |
| 1890 | COMPATIBLE_IOCTL(TIOCSPGRP) | 958 | COMPATIBLE_IOCTL(TIOCSPGRP) |
| 1891 | COMPATIBLE_IOCTL(TIOCGPGRP) | 959 | COMPATIBLE_IOCTL(TIOCGPGRP) |
| 1892 | ULONG_IOCTL(TIOCSCTTY) | ||
| 1893 | COMPATIBLE_IOCTL(TIOCGPTN) | 960 | COMPATIBLE_IOCTL(TIOCGPTN) |
| 1894 | COMPATIBLE_IOCTL(TIOCSPTLCK) | 961 | COMPATIBLE_IOCTL(TIOCSPTLCK) |
| 1895 | COMPATIBLE_IOCTL(TIOCSERGETLSR) | 962 | COMPATIBLE_IOCTL(TIOCSERGETLSR) |
| @@ -1912,44 +979,11 @@ COMPATIBLE_IOCTL(FIGETBSZ) | |||
| 1912 | /* 'X' - originally XFS but some now in the VFS */ | 979 | /* 'X' - originally XFS but some now in the VFS */ |
| 1913 | COMPATIBLE_IOCTL(FIFREEZE) | 980 | COMPATIBLE_IOCTL(FIFREEZE) |
| 1914 | COMPATIBLE_IOCTL(FITHAW) | 981 | COMPATIBLE_IOCTL(FITHAW) |
| 1915 | /* RAID */ | ||
| 1916 | COMPATIBLE_IOCTL(RAID_VERSION) | ||
| 1917 | COMPATIBLE_IOCTL(GET_ARRAY_INFO) | ||
| 1918 | COMPATIBLE_IOCTL(GET_DISK_INFO) | ||
| 1919 | COMPATIBLE_IOCTL(PRINT_RAID_DEBUG) | ||
| 1920 | COMPATIBLE_IOCTL(RAID_AUTORUN) | ||
| 1921 | COMPATIBLE_IOCTL(CLEAR_ARRAY) | ||
| 1922 | COMPATIBLE_IOCTL(ADD_NEW_DISK) | ||
| 1923 | ULONG_IOCTL(HOT_REMOVE_DISK) | ||
| 1924 | COMPATIBLE_IOCTL(SET_ARRAY_INFO) | ||
| 1925 | COMPATIBLE_IOCTL(SET_DISK_INFO) | ||
| 1926 | COMPATIBLE_IOCTL(WRITE_RAID_INFO) | ||
| 1927 | COMPATIBLE_IOCTL(UNPROTECT_ARRAY) | ||
| 1928 | COMPATIBLE_IOCTL(PROTECT_ARRAY) | ||
| 1929 | ULONG_IOCTL(HOT_ADD_DISK) | ||
| 1930 | ULONG_IOCTL(SET_DISK_FAULTY) | ||
| 1931 | COMPATIBLE_IOCTL(RUN_ARRAY) | ||
| 1932 | COMPATIBLE_IOCTL(STOP_ARRAY) | ||
| 1933 | COMPATIBLE_IOCTL(STOP_ARRAY_RO) | ||
| 1934 | COMPATIBLE_IOCTL(RESTART_ARRAY_RW) | ||
| 1935 | COMPATIBLE_IOCTL(GET_BITMAP_FILE) | ||
| 1936 | ULONG_IOCTL(SET_BITMAP_FILE) | ||
| 1937 | /* Big K */ | ||
| 1938 | COMPATIBLE_IOCTL(PIO_FONT) | ||
| 1939 | COMPATIBLE_IOCTL(GIO_FONT) | ||
| 1940 | COMPATIBLE_IOCTL(PIO_CMAP) | ||
| 1941 | COMPATIBLE_IOCTL(GIO_CMAP) | ||
| 1942 | ULONG_IOCTL(KDSIGACCEPT) | ||
| 1943 | COMPATIBLE_IOCTL(KDGETKEYCODE) | 982 | COMPATIBLE_IOCTL(KDGETKEYCODE) |
| 1944 | COMPATIBLE_IOCTL(KDSETKEYCODE) | 983 | COMPATIBLE_IOCTL(KDSETKEYCODE) |
| 1945 | ULONG_IOCTL(KIOCSOUND) | ||
| 1946 | ULONG_IOCTL(KDMKTONE) | ||
| 1947 | COMPATIBLE_IOCTL(KDGKBTYPE) | 984 | COMPATIBLE_IOCTL(KDGKBTYPE) |
| 1948 | ULONG_IOCTL(KDSETMODE) | ||
| 1949 | COMPATIBLE_IOCTL(KDGETMODE) | 985 | COMPATIBLE_IOCTL(KDGETMODE) |
| 1950 | ULONG_IOCTL(KDSKBMODE) | ||
| 1951 | COMPATIBLE_IOCTL(KDGKBMODE) | 986 | COMPATIBLE_IOCTL(KDGKBMODE) |
| 1952 | ULONG_IOCTL(KDSKBMETA) | ||
| 1953 | COMPATIBLE_IOCTL(KDGKBMETA) | 987 | COMPATIBLE_IOCTL(KDGKBMETA) |
| 1954 | COMPATIBLE_IOCTL(KDGKBENT) | 988 | COMPATIBLE_IOCTL(KDGKBENT) |
| 1955 | COMPATIBLE_IOCTL(KDSKBENT) | 989 | COMPATIBLE_IOCTL(KDSKBENT) |
| @@ -1959,15 +993,7 @@ COMPATIBLE_IOCTL(KDGKBDIACR) | |||
| 1959 | COMPATIBLE_IOCTL(KDSKBDIACR) | 993 | COMPATIBLE_IOCTL(KDSKBDIACR) |
| 1960 | COMPATIBLE_IOCTL(KDKBDREP) | 994 | COMPATIBLE_IOCTL(KDKBDREP) |
| 1961 | COMPATIBLE_IOCTL(KDGKBLED) | 995 | COMPATIBLE_IOCTL(KDGKBLED) |
| 1962 | ULONG_IOCTL(KDSKBLED) | ||
| 1963 | COMPATIBLE_IOCTL(KDGETLED) | 996 | COMPATIBLE_IOCTL(KDGETLED) |
| 1964 | ULONG_IOCTL(KDSETLED) | ||
| 1965 | COMPATIBLE_IOCTL(GIO_SCRNMAP) | ||
| 1966 | COMPATIBLE_IOCTL(PIO_SCRNMAP) | ||
| 1967 | COMPATIBLE_IOCTL(GIO_UNISCRNMAP) | ||
| 1968 | COMPATIBLE_IOCTL(PIO_UNISCRNMAP) | ||
| 1969 | COMPATIBLE_IOCTL(PIO_FONTRESET) | ||
| 1970 | COMPATIBLE_IOCTL(PIO_UNIMAPCLR) | ||
| 1971 | #ifdef CONFIG_BLOCK | 997 | #ifdef CONFIG_BLOCK |
| 1972 | /* Big S */ | 998 | /* Big S */ |
| 1973 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) | 999 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN) |
| @@ -1979,32 +1005,6 @@ COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND) | |||
| 1979 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) | 1005 | COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST) |
| 1980 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) | 1006 | COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI) |
| 1981 | #endif | 1007 | #endif |
| 1982 | /* Big T */ | ||
| 1983 | COMPATIBLE_IOCTL(TUNSETNOCSUM) | ||
| 1984 | COMPATIBLE_IOCTL(TUNSETDEBUG) | ||
| 1985 | COMPATIBLE_IOCTL(TUNSETPERSIST) | ||
| 1986 | COMPATIBLE_IOCTL(TUNSETOWNER) | ||
| 1987 | COMPATIBLE_IOCTL(TUNSETLINK) | ||
| 1988 | COMPATIBLE_IOCTL(TUNSETGROUP) | ||
| 1989 | COMPATIBLE_IOCTL(TUNGETFEATURES) | ||
| 1990 | COMPATIBLE_IOCTL(TUNSETOFFLOAD) | ||
| 1991 | COMPATIBLE_IOCTL(TUNSETTXFILTER) | ||
| 1992 | COMPATIBLE_IOCTL(TUNGETSNDBUF) | ||
| 1993 | COMPATIBLE_IOCTL(TUNSETSNDBUF) | ||
| 1994 | /* Big V */ | ||
| 1995 | COMPATIBLE_IOCTL(VT_SETMODE) | ||
| 1996 | COMPATIBLE_IOCTL(VT_GETMODE) | ||
| 1997 | COMPATIBLE_IOCTL(VT_GETSTATE) | ||
| 1998 | COMPATIBLE_IOCTL(VT_OPENQRY) | ||
| 1999 | ULONG_IOCTL(VT_ACTIVATE) | ||
| 2000 | ULONG_IOCTL(VT_WAITACTIVE) | ||
| 2001 | ULONG_IOCTL(VT_RELDISP) | ||
| 2002 | ULONG_IOCTL(VT_DISALLOCATE) | ||
| 2003 | COMPATIBLE_IOCTL(VT_RESIZE) | ||
| 2004 | COMPATIBLE_IOCTL(VT_RESIZEX) | ||
| 2005 | COMPATIBLE_IOCTL(VT_LOCKSWITCH) | ||
| 2006 | COMPATIBLE_IOCTL(VT_UNLOCKSWITCH) | ||
| 2007 | COMPATIBLE_IOCTL(VT_GETHIFONTMASK) | ||
| 2008 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ | 1008 | /* Little p (/dev/rtc, /dev/envctrl, etc.) */ |
| 2009 | COMPATIBLE_IOCTL(RTC_AIE_ON) | 1009 | COMPATIBLE_IOCTL(RTC_AIE_ON) |
| 2010 | COMPATIBLE_IOCTL(RTC_AIE_OFF) | 1010 | COMPATIBLE_IOCTL(RTC_AIE_OFF) |
| @@ -2032,36 +1032,13 @@ COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */ | |||
| 2032 | COMPATIBLE_IOCTL(MTIOCTOP) | 1032 | COMPATIBLE_IOCTL(MTIOCTOP) |
| 2033 | /* Socket level stuff */ | 1033 | /* Socket level stuff */ |
| 2034 | COMPATIBLE_IOCTL(FIOQSIZE) | 1034 | COMPATIBLE_IOCTL(FIOQSIZE) |
| 2035 | COMPATIBLE_IOCTL(FIOSETOWN) | ||
| 2036 | COMPATIBLE_IOCTL(SIOCSPGRP) | ||
| 2037 | COMPATIBLE_IOCTL(FIOGETOWN) | ||
| 2038 | COMPATIBLE_IOCTL(SIOCGPGRP) | ||
| 2039 | COMPATIBLE_IOCTL(SIOCATMARK) | ||
| 2040 | COMPATIBLE_IOCTL(SIOCSIFLINK) | ||
| 2041 | COMPATIBLE_IOCTL(SIOCSIFENCAP) | ||
| 2042 | COMPATIBLE_IOCTL(SIOCGIFENCAP) | ||
| 2043 | COMPATIBLE_IOCTL(SIOCSIFNAME) | ||
| 2044 | COMPATIBLE_IOCTL(SIOCSARP) | ||
| 2045 | COMPATIBLE_IOCTL(SIOCGARP) | ||
| 2046 | COMPATIBLE_IOCTL(SIOCDARP) | ||
| 2047 | COMPATIBLE_IOCTL(SIOCSRARP) | ||
| 2048 | COMPATIBLE_IOCTL(SIOCGRARP) | ||
| 2049 | COMPATIBLE_IOCTL(SIOCDRARP) | ||
| 2050 | COMPATIBLE_IOCTL(SIOCADDDLCI) | ||
| 2051 | COMPATIBLE_IOCTL(SIOCDELDLCI) | ||
| 2052 | COMPATIBLE_IOCTL(SIOCGMIIPHY) | ||
| 2053 | COMPATIBLE_IOCTL(SIOCGMIIREG) | ||
| 2054 | COMPATIBLE_IOCTL(SIOCSMIIREG) | ||
| 2055 | COMPATIBLE_IOCTL(SIOCGIFVLAN) | ||
| 2056 | COMPATIBLE_IOCTL(SIOCSIFVLAN) | ||
| 2057 | COMPATIBLE_IOCTL(SIOCBRADDBR) | ||
| 2058 | COMPATIBLE_IOCTL(SIOCBRDELBR) | ||
| 2059 | #ifdef CONFIG_BLOCK | 1035 | #ifdef CONFIG_BLOCK |
| 1036 | /* loop */ | ||
| 1037 | IGNORE_IOCTL(LOOP_CLR_FD) | ||
| 2060 | /* SG stuff */ | 1038 | /* SG stuff */ |
| 2061 | COMPATIBLE_IOCTL(SG_SET_TIMEOUT) | 1039 | COMPATIBLE_IOCTL(SG_SET_TIMEOUT) |
| 2062 | COMPATIBLE_IOCTL(SG_GET_TIMEOUT) | 1040 | COMPATIBLE_IOCTL(SG_GET_TIMEOUT) |
| 2063 | COMPATIBLE_IOCTL(SG_EMULATED_HOST) | 1041 | COMPATIBLE_IOCTL(SG_EMULATED_HOST) |
| 2064 | ULONG_IOCTL(SG_SET_TRANSFORM) | ||
| 2065 | COMPATIBLE_IOCTL(SG_GET_TRANSFORM) | 1042 | COMPATIBLE_IOCTL(SG_GET_TRANSFORM) |
| 2066 | COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE) | 1043 | COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE) |
| 2067 | COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE) | 1044 | COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE) |
| @@ -2115,8 +1092,6 @@ COMPATIBLE_IOCTL(PPPIOCGCHAN) | |||
| 2115 | /* PPPOX */ | 1092 | /* PPPOX */ |
| 2116 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) | 1093 | COMPATIBLE_IOCTL(PPPOEIOCSFWD) |
| 2117 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) | 1094 | COMPATIBLE_IOCTL(PPPOEIOCDFWD) |
| 2118 | /* LP */ | ||
| 2119 | COMPATIBLE_IOCTL(LPGETSTATUS) | ||
| 2120 | /* ppdev */ | 1095 | /* ppdev */ |
| 2121 | COMPATIBLE_IOCTL(PPSETMODE) | 1096 | COMPATIBLE_IOCTL(PPSETMODE) |
| 2122 | COMPATIBLE_IOCTL(PPRSTATUS) | 1097 | COMPATIBLE_IOCTL(PPRSTATUS) |
| @@ -2298,8 +1273,6 @@ COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS) | |||
| 2298 | COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) | 1273 | COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS) |
| 2299 | COMPATIBLE_IOCTL(OSS_GETVERSION) | 1274 | COMPATIBLE_IOCTL(OSS_GETVERSION) |
| 2300 | /* AUTOFS */ | 1275 | /* AUTOFS */ |
| 2301 | ULONG_IOCTL(AUTOFS_IOC_READY) | ||
| 2302 | ULONG_IOCTL(AUTOFS_IOC_FAIL) | ||
| 2303 | COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) | 1276 | COMPATIBLE_IOCTL(AUTOFS_IOC_CATATONIC) |
| 2304 | COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) | 1277 | COMPATIBLE_IOCTL(AUTOFS_IOC_PROTOVER) |
| 2305 | COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) | 1278 | COMPATIBLE_IOCTL(AUTOFS_IOC_EXPIRE) |
| @@ -2311,22 +1284,6 @@ COMPATIBLE_IOCTL(RAW_SETBIND) | |||
| 2311 | COMPATIBLE_IOCTL(RAW_GETBIND) | 1284 | COMPATIBLE_IOCTL(RAW_GETBIND) |
| 2312 | /* SMB ioctls which do not need any translations */ | 1285 | /* SMB ioctls which do not need any translations */ |
| 2313 | COMPATIBLE_IOCTL(SMB_IOC_NEWCONN) | 1286 | COMPATIBLE_IOCTL(SMB_IOC_NEWCONN) |
| 2314 | /* Little a */ | ||
| 2315 | COMPATIBLE_IOCTL(ATMSIGD_CTRL) | ||
| 2316 | COMPATIBLE_IOCTL(ATMARPD_CTRL) | ||
| 2317 | COMPATIBLE_IOCTL(ATMLEC_CTRL) | ||
| 2318 | COMPATIBLE_IOCTL(ATMLEC_MCAST) | ||
| 2319 | COMPATIBLE_IOCTL(ATMLEC_DATA) | ||
| 2320 | COMPATIBLE_IOCTL(ATM_SETSC) | ||
| 2321 | COMPATIBLE_IOCTL(SIOCSIFATMTCP) | ||
| 2322 | COMPATIBLE_IOCTL(SIOCMKCLIP) | ||
| 2323 | COMPATIBLE_IOCTL(ATMARP_MKIP) | ||
| 2324 | COMPATIBLE_IOCTL(ATMARP_SETENTRY) | ||
| 2325 | COMPATIBLE_IOCTL(ATMARP_ENCAP) | ||
| 2326 | COMPATIBLE_IOCTL(ATMTCP_CREATE) | ||
| 2327 | COMPATIBLE_IOCTL(ATMTCP_REMOVE) | ||
| 2328 | COMPATIBLE_IOCTL(ATMMPC_CTRL) | ||
| 2329 | COMPATIBLE_IOCTL(ATMMPC_DATA) | ||
| 2330 | /* Watchdog */ | 1287 | /* Watchdog */ |
| 2331 | COMPATIBLE_IOCTL(WDIOC_GETSUPPORT) | 1288 | COMPATIBLE_IOCTL(WDIOC_GETSUPPORT) |
| 2332 | COMPATIBLE_IOCTL(WDIOC_GETSTATUS) | 1289 | COMPATIBLE_IOCTL(WDIOC_GETSTATUS) |
| @@ -2408,30 +1365,11 @@ COMPATIBLE_IOCTL(PCIIOC_CONTROLLER) | |||
| 2408 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO) | 1365 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO) |
| 2409 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM) | 1366 | COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM) |
| 2410 | COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE) | 1367 | COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE) |
| 2411 | /* USB */ | ||
| 2412 | COMPATIBLE_IOCTL(USBDEVFS_RESETEP) | ||
| 2413 | COMPATIBLE_IOCTL(USBDEVFS_SETINTERFACE) | ||
| 2414 | COMPATIBLE_IOCTL(USBDEVFS_SETCONFIGURATION) | ||
| 2415 | COMPATIBLE_IOCTL(USBDEVFS_GETDRIVER) | ||
| 2416 | COMPATIBLE_IOCTL(USBDEVFS_DISCARDURB) | ||
| 2417 | COMPATIBLE_IOCTL(USBDEVFS_CLAIMINTERFACE) | ||
| 2418 | COMPATIBLE_IOCTL(USBDEVFS_RELEASEINTERFACE) | ||
| 2419 | COMPATIBLE_IOCTL(USBDEVFS_CONNECTINFO) | ||
| 2420 | COMPATIBLE_IOCTL(USBDEVFS_HUB_PORTINFO) | ||
| 2421 | COMPATIBLE_IOCTL(USBDEVFS_RESET) | ||
| 2422 | COMPATIBLE_IOCTL(USBDEVFS_SUBMITURB32) | ||
| 2423 | COMPATIBLE_IOCTL(USBDEVFS_REAPURB32) | ||
| 2424 | COMPATIBLE_IOCTL(USBDEVFS_REAPURBNDELAY32) | ||
| 2425 | COMPATIBLE_IOCTL(USBDEVFS_CLEAR_HALT) | ||
| 2426 | /* NBD */ | 1368 | /* NBD */ |
| 2427 | ULONG_IOCTL(NBD_SET_SOCK) | ||
| 2428 | ULONG_IOCTL(NBD_SET_BLKSIZE) | ||
| 2429 | ULONG_IOCTL(NBD_SET_SIZE) | ||
| 2430 | COMPATIBLE_IOCTL(NBD_DO_IT) | 1369 | COMPATIBLE_IOCTL(NBD_DO_IT) |
| 2431 | COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) | 1370 | COMPATIBLE_IOCTL(NBD_CLEAR_SOCK) |
| 2432 | COMPATIBLE_IOCTL(NBD_CLEAR_QUE) | 1371 | COMPATIBLE_IOCTL(NBD_CLEAR_QUE) |
| 2433 | COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) | 1372 | COMPATIBLE_IOCTL(NBD_PRINT_DEBUG) |
| 2434 | ULONG_IOCTL(NBD_SET_SIZE_BLOCKS) | ||
| 2435 | COMPATIBLE_IOCTL(NBD_DISCONNECT) | 1373 | COMPATIBLE_IOCTL(NBD_DISCONNECT) |
| 2436 | /* i2c */ | 1374 | /* i2c */ |
| 2437 | COMPATIBLE_IOCTL(I2C_SLAVE) | 1375 | COMPATIBLE_IOCTL(I2C_SLAVE) |
| @@ -2531,131 +1469,13 @@ COMPATIBLE_IOCTL(JSIOCGAXES) | |||
| 2531 | COMPATIBLE_IOCTL(JSIOCGBUTTONS) | 1469 | COMPATIBLE_IOCTL(JSIOCGBUTTONS) |
| 2532 | COMPATIBLE_IOCTL(JSIOCGNAME(0)) | 1470 | COMPATIBLE_IOCTL(JSIOCGNAME(0)) |
| 2533 | 1471 | ||
| 2534 | /* now things that need handlers */ | ||
| 2535 | #ifdef CONFIG_NET | ||
| 2536 | HANDLE_IOCTL(SIOCGIFNAME, dev_ifname32) | ||
| 2537 | HANDLE_IOCTL(SIOCGIFCONF, dev_ifconf) | ||
| 2538 | HANDLE_IOCTL(SIOCGIFFLAGS, dev_ifsioc) | ||
| 2539 | HANDLE_IOCTL(SIOCSIFFLAGS, dev_ifsioc) | ||
| 2540 | HANDLE_IOCTL(SIOCGIFMETRIC, dev_ifsioc) | ||
| 2541 | HANDLE_IOCTL(SIOCSIFMETRIC, dev_ifsioc) | ||
| 2542 | HANDLE_IOCTL(SIOCGIFMTU, dev_ifsioc) | ||
| 2543 | HANDLE_IOCTL(SIOCSIFMTU, dev_ifsioc) | ||
| 2544 | HANDLE_IOCTL(SIOCGIFMEM, dev_ifsioc) | ||
| 2545 | HANDLE_IOCTL(SIOCSIFMEM, dev_ifsioc) | ||
| 2546 | HANDLE_IOCTL(SIOCGIFHWADDR, dev_ifsioc) | ||
| 2547 | HANDLE_IOCTL(SIOCSIFHWADDR, dev_ifsioc) | ||
| 2548 | HANDLE_IOCTL(SIOCADDMULTI, dev_ifsioc) | ||
| 2549 | HANDLE_IOCTL(SIOCDELMULTI, dev_ifsioc) | ||
| 2550 | HANDLE_IOCTL(SIOCGIFINDEX, dev_ifsioc) | ||
| 2551 | HANDLE_IOCTL(SIOCGIFMAP, dev_ifsioc) | ||
| 2552 | HANDLE_IOCTL(SIOCSIFMAP, dev_ifsioc) | ||
| 2553 | HANDLE_IOCTL(SIOCGIFADDR, dev_ifsioc) | ||
| 2554 | HANDLE_IOCTL(SIOCSIFADDR, dev_ifsioc) | ||
| 2555 | HANDLE_IOCTL(SIOCSIFHWBROADCAST, dev_ifsioc) | ||
| 2556 | HANDLE_IOCTL(SIOCSHWTSTAMP, dev_ifsioc) | ||
| 2557 | |||
| 2558 | /* ioctls used by appletalk ddp.c */ | ||
| 2559 | HANDLE_IOCTL(SIOCATALKDIFADDR, dev_ifsioc) | ||
| 2560 | HANDLE_IOCTL(SIOCDIFADDR, dev_ifsioc) | ||
| 2561 | HANDLE_IOCTL(SIOCSARP, dev_ifsioc) | ||
| 2562 | HANDLE_IOCTL(SIOCDARP, dev_ifsioc) | ||
| 2563 | |||
| 2564 | HANDLE_IOCTL(SIOCGIFBRDADDR, dev_ifsioc) | ||
| 2565 | HANDLE_IOCTL(SIOCSIFBRDADDR, dev_ifsioc) | ||
| 2566 | HANDLE_IOCTL(SIOCGIFDSTADDR, dev_ifsioc) | ||
| 2567 | HANDLE_IOCTL(SIOCSIFDSTADDR, dev_ifsioc) | ||
| 2568 | HANDLE_IOCTL(SIOCGIFNETMASK, dev_ifsioc) | ||
| 2569 | HANDLE_IOCTL(SIOCSIFNETMASK, dev_ifsioc) | ||
| 2570 | HANDLE_IOCTL(SIOCSIFPFLAGS, dev_ifsioc) | ||
| 2571 | HANDLE_IOCTL(SIOCGIFPFLAGS, dev_ifsioc) | ||
| 2572 | HANDLE_IOCTL(SIOCGIFTXQLEN, dev_ifsioc) | ||
| 2573 | HANDLE_IOCTL(SIOCSIFTXQLEN, dev_ifsioc) | ||
| 2574 | HANDLE_IOCTL(TUNSETIFF, dev_ifsioc) | ||
| 2575 | HANDLE_IOCTL(TUNGETIFF, dev_ifsioc) | ||
| 2576 | HANDLE_IOCTL(SIOCETHTOOL, ethtool_ioctl) | ||
| 2577 | HANDLE_IOCTL(SIOCBONDENSLAVE, bond_ioctl) | ||
| 2578 | HANDLE_IOCTL(SIOCBONDRELEASE, bond_ioctl) | ||
| 2579 | HANDLE_IOCTL(SIOCBONDSETHWADDR, bond_ioctl) | ||
| 2580 | HANDLE_IOCTL(SIOCBONDSLAVEINFOQUERY, bond_ioctl) | ||
| 2581 | HANDLE_IOCTL(SIOCBONDINFOQUERY, bond_ioctl) | ||
| 2582 | HANDLE_IOCTL(SIOCBONDCHANGEACTIVE, bond_ioctl) | ||
| 2583 | HANDLE_IOCTL(SIOCADDRT, routing_ioctl) | ||
| 2584 | HANDLE_IOCTL(SIOCDELRT, routing_ioctl) | ||
| 2585 | HANDLE_IOCTL(SIOCBRADDIF, dev_ifsioc) | ||
| 2586 | HANDLE_IOCTL(SIOCBRDELIF, dev_ifsioc) | ||
| 2587 | /* Note SIOCRTMSG is no longer, so this is safe and * the user would have seen just an -EINVAL anyways. */ | ||
| 2588 | HANDLE_IOCTL(SIOCRTMSG, ret_einval) | ||
| 2589 | HANDLE_IOCTL(SIOCGSTAMP, do_siocgstamp) | ||
| 2590 | HANDLE_IOCTL(SIOCGSTAMPNS, do_siocgstampns) | ||
| 2591 | #endif | ||
| 2592 | #ifdef CONFIG_BLOCK | ||
| 2593 | HANDLE_IOCTL(SG_IO,sg_ioctl_trans) | ||
| 2594 | HANDLE_IOCTL(SG_GET_REQUEST_TABLE, sg_grt_trans) | ||
| 2595 | #endif | ||
| 2596 | HANDLE_IOCTL(PPPIOCGIDLE32, ppp_ioctl_trans) | ||
| 2597 | HANDLE_IOCTL(PPPIOCSCOMPRESS32, ppp_ioctl_trans) | ||
| 2598 | HANDLE_IOCTL(PPPIOCSPASS32, ppp_sock_fprog_ioctl_trans) | ||
| 2599 | HANDLE_IOCTL(PPPIOCSACTIVE32, ppp_sock_fprog_ioctl_trans) | ||
| 2600 | #ifdef CONFIG_BLOCK | ||
| 2601 | HANDLE_IOCTL(MTIOCGET32, mt_ioctl_trans) | ||
| 2602 | HANDLE_IOCTL(MTIOCPOS32, mt_ioctl_trans) | ||
| 2603 | #endif | ||
| 2604 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | ||
| 2605 | HANDLE_IOCTL(AUTOFS_IOC_SETTIMEOUT32, ioc_settimeout) | ||
| 2606 | #ifdef CONFIG_VT | ||
| 2607 | HANDLE_IOCTL(PIO_FONTX, do_fontx_ioctl) | ||
| 2608 | HANDLE_IOCTL(GIO_FONTX, do_fontx_ioctl) | ||
| 2609 | HANDLE_IOCTL(PIO_UNIMAP, do_unimap_ioctl) | ||
| 2610 | HANDLE_IOCTL(GIO_UNIMAP, do_unimap_ioctl) | ||
| 2611 | HANDLE_IOCTL(KDFONTOP, do_kdfontop_ioctl) | ||
| 2612 | #endif | ||
| 2613 | /* One SMB ioctl needs translations. */ | ||
| 2614 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | ||
| 2615 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) | ||
| 2616 | HANDLE_IOCTL(ATM_GETLINKRATE32, do_atm_ioctl) | ||
| 2617 | HANDLE_IOCTL(ATM_GETNAMES32, do_atm_ioctl) | ||
| 2618 | HANDLE_IOCTL(ATM_GETTYPE32, do_atm_ioctl) | ||
| 2619 | HANDLE_IOCTL(ATM_GETESI32, do_atm_ioctl) | ||
| 2620 | HANDLE_IOCTL(ATM_GETADDR32, do_atm_ioctl) | ||
| 2621 | HANDLE_IOCTL(ATM_RSTADDR32, do_atm_ioctl) | ||
| 2622 | HANDLE_IOCTL(ATM_ADDADDR32, do_atm_ioctl) | ||
| 2623 | HANDLE_IOCTL(ATM_DELADDR32, do_atm_ioctl) | ||
| 2624 | HANDLE_IOCTL(ATM_GETCIRANGE32, do_atm_ioctl) | ||
| 2625 | HANDLE_IOCTL(ATM_SETCIRANGE32, do_atm_ioctl) | ||
| 2626 | HANDLE_IOCTL(ATM_SETESI32, do_atm_ioctl) | ||
| 2627 | HANDLE_IOCTL(ATM_SETESIF32, do_atm_ioctl) | ||
| 2628 | HANDLE_IOCTL(ATM_GETSTAT32, do_atm_ioctl) | ||
| 2629 | HANDLE_IOCTL(ATM_GETSTATZ32, do_atm_ioctl) | ||
| 2630 | HANDLE_IOCTL(ATM_GETLOOP32, do_atm_ioctl) | ||
| 2631 | HANDLE_IOCTL(ATM_SETLOOP32, do_atm_ioctl) | ||
| 2632 | HANDLE_IOCTL(ATM_QUERYLOOP32, do_atm_ioctl) | ||
| 2633 | HANDLE_IOCTL(SONET_GETSTAT, do_atm_ioctl) | ||
| 2634 | HANDLE_IOCTL(SONET_GETSTATZ, do_atm_ioctl) | ||
| 2635 | HANDLE_IOCTL(SONET_GETDIAG, do_atm_ioctl) | ||
| 2636 | HANDLE_IOCTL(SONET_SETDIAG, do_atm_ioctl) | ||
| 2637 | HANDLE_IOCTL(SONET_CLRDIAG, do_atm_ioctl) | ||
| 2638 | HANDLE_IOCTL(SONET_SETFRAMING, do_atm_ioctl) | ||
| 2639 | HANDLE_IOCTL(SONET_GETFRAMING, do_atm_ioctl) | ||
| 2640 | HANDLE_IOCTL(SONET_GETFRSENSE, do_atm_ioctl) | ||
| 2641 | /* block stuff */ | ||
| 2642 | #ifdef CONFIG_BLOCK | ||
| 2643 | /* loop */ | ||
| 2644 | IGNORE_IOCTL(LOOP_CLR_FD) | ||
| 2645 | /* Raw devices */ | ||
| 2646 | HANDLE_IOCTL(RAW_SETBIND, raw_ioctl) | ||
| 2647 | HANDLE_IOCTL(RAW_GETBIND, raw_ioctl) | ||
| 2648 | #endif | ||
| 2649 | /* Serial */ | ||
| 2650 | HANDLE_IOCTL(TIOCGSERIAL, serial_struct_ioctl) | ||
| 2651 | HANDLE_IOCTL(TIOCSSERIAL, serial_struct_ioctl) | ||
| 2652 | #ifdef TIOCGLTC | 1472 | #ifdef TIOCGLTC |
| 2653 | COMPATIBLE_IOCTL(TIOCGLTC) | 1473 | COMPATIBLE_IOCTL(TIOCGLTC) |
| 2654 | COMPATIBLE_IOCTL(TIOCSLTC) | 1474 | COMPATIBLE_IOCTL(TIOCSLTC) |
| 2655 | #endif | 1475 | #endif |
| 2656 | #ifdef TIOCSTART | 1476 | #ifdef TIOCSTART |
| 2657 | /* | 1477 | /* |
| 2658 | * For these two we have defintions in ioctls.h and/or termios.h on | 1478 | * For these two we have definitions in ioctls.h and/or termios.h on |
| 2659 | * some architectures but no actual implemention. Some applications | 1479 | * some architectures but no actual implemention. Some applications |
| 2660 | * like bash call them if they are defined in the headers, so we provide | 1480 | * like bash call them if they are defined in the headers, so we provide |
| 2661 | * entries here to avoid syslog message spew. | 1481 | * entries here to avoid syslog message spew. |
| @@ -2663,43 +1483,6 @@ COMPATIBLE_IOCTL(TIOCSLTC) | |||
| 2663 | COMPATIBLE_IOCTL(TIOCSTART) | 1483 | COMPATIBLE_IOCTL(TIOCSTART) |
| 2664 | COMPATIBLE_IOCTL(TIOCSTOP) | 1484 | COMPATIBLE_IOCTL(TIOCSTOP) |
| 2665 | #endif | 1485 | #endif |
| 2666 | /* Usbdevfs */ | ||
| 2667 | HANDLE_IOCTL(USBDEVFS_CONTROL32, do_usbdevfs_control) | ||
| 2668 | HANDLE_IOCTL(USBDEVFS_BULK32, do_usbdevfs_bulk) | ||
| 2669 | HANDLE_IOCTL(USBDEVFS_DISCSIGNAL32, do_usbdevfs_discsignal) | ||
| 2670 | COMPATIBLE_IOCTL(USBDEVFS_IOCTL32) | ||
| 2671 | /* i2c */ | ||
| 2672 | HANDLE_IOCTL(I2C_FUNCS, w_long) | ||
| 2673 | HANDLE_IOCTL(I2C_RDWR, do_i2c_rdwr_ioctl) | ||
| 2674 | HANDLE_IOCTL(I2C_SMBUS, do_i2c_smbus_ioctl) | ||
| 2675 | /* bridge */ | ||
| 2676 | HANDLE_IOCTL(SIOCSIFBR, old_bridge_ioctl) | ||
| 2677 | HANDLE_IOCTL(SIOCGIFBR, old_bridge_ioctl) | ||
| 2678 | /* Not implemented in the native kernel */ | ||
| 2679 | IGNORE_IOCTL(SIOCGIFCOUNT) | ||
| 2680 | HANDLE_IOCTL(RTC_IRQP_READ32, rtc_ioctl) | ||
| 2681 | HANDLE_IOCTL(RTC_IRQP_SET32, rtc_ioctl) | ||
| 2682 | HANDLE_IOCTL(RTC_EPOCH_READ32, rtc_ioctl) | ||
| 2683 | HANDLE_IOCTL(RTC_EPOCH_SET32, rtc_ioctl) | ||
| 2684 | |||
| 2685 | /* dvb */ | ||
| 2686 | HANDLE_IOCTL(VIDEO_GET_EVENT, do_video_get_event) | ||
| 2687 | HANDLE_IOCTL(VIDEO_STILLPICTURE, do_video_stillpicture) | ||
| 2688 | HANDLE_IOCTL(VIDEO_SET_SPU_PALETTE, do_video_set_spu_palette) | ||
| 2689 | |||
| 2690 | /* parport */ | ||
| 2691 | COMPATIBLE_IOCTL(LPTIME) | ||
| 2692 | COMPATIBLE_IOCTL(LPCHAR) | ||
| 2693 | COMPATIBLE_IOCTL(LPABORTOPEN) | ||
| 2694 | COMPATIBLE_IOCTL(LPCAREFUL) | ||
| 2695 | COMPATIBLE_IOCTL(LPWAIT) | ||
| 2696 | COMPATIBLE_IOCTL(LPSETIRQ) | ||
| 2697 | COMPATIBLE_IOCTL(LPGETSTATUS) | ||
| 2698 | COMPATIBLE_IOCTL(LPGETSTATUS) | ||
| 2699 | COMPATIBLE_IOCTL(LPRESET) | ||
| 2700 | /*LPGETSTATS not implemented, but no kernels seem to compile it in anyways*/ | ||
| 2701 | COMPATIBLE_IOCTL(LPGETFLAGS) | ||
| 2702 | HANDLE_IOCTL(LPSETTIMEOUT, lp_timeout_trans) | ||
| 2703 | 1486 | ||
| 2704 | /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, | 1487 | /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl, |
| 2705 | but we don't want warnings on other file systems. So declare | 1488 | but we don't want warnings on other file systems. So declare |
| @@ -2727,12 +1510,110 @@ IGNORE_IOCTL(FBIOGCURSOR32) | |||
| 2727 | #endif | 1510 | #endif |
| 2728 | }; | 1511 | }; |
| 2729 | 1512 | ||
| 2730 | #define IOCTL_HASHSIZE 256 | 1513 | /* |
| 2731 | static struct ioctl_trans *ioctl32_hash_table[IOCTL_HASHSIZE]; | 1514 | * Convert common ioctl arguments based on their command number |
| 2732 | 1515 | * | |
| 2733 | static inline unsigned long ioctl32_hash(unsigned long cmd) | 1516 | * Please do not add any code in here. Instead, implement |
| 1517 | * a compat_ioctl operation in the place that handleѕ the | ||
| 1518 | * ioctl for the native case. | ||
| 1519 | */ | ||
| 1520 | static long do_ioctl_trans(int fd, unsigned int cmd, | ||
| 1521 | unsigned long arg, struct file *file) | ||
| 2734 | { | 1522 | { |
| 2735 | return (((cmd >> 6) ^ (cmd >> 4) ^ cmd)) % IOCTL_HASHSIZE; | 1523 | void __user *argp = compat_ptr(arg); |
| 1524 | |||
| 1525 | switch (cmd) { | ||
| 1526 | case PPPIOCGIDLE32: | ||
| 1527 | return ppp_gidle(fd, cmd, argp); | ||
| 1528 | case PPPIOCSCOMPRESS32: | ||
| 1529 | return ppp_scompress(fd, cmd, argp); | ||
| 1530 | case PPPIOCSPASS32: | ||
| 1531 | case PPPIOCSACTIVE32: | ||
| 1532 | return ppp_sock_fprog_ioctl_trans(fd, cmd, argp); | ||
| 1533 | #ifdef CONFIG_BLOCK | ||
| 1534 | case SG_IO: | ||
| 1535 | return sg_ioctl_trans(fd, cmd, argp); | ||
| 1536 | case SG_GET_REQUEST_TABLE: | ||
| 1537 | return sg_grt_trans(fd, cmd, argp); | ||
| 1538 | case MTIOCGET32: | ||
| 1539 | case MTIOCPOS32: | ||
| 1540 | return mt_ioctl_trans(fd, cmd, argp); | ||
| 1541 | /* Raw devices */ | ||
| 1542 | case RAW_SETBIND: | ||
| 1543 | case RAW_GETBIND: | ||
| 1544 | return raw_ioctl(fd, cmd, argp); | ||
| 1545 | #endif | ||
| 1546 | #define AUTOFS_IOC_SETTIMEOUT32 _IOWR(0x93,0x64,unsigned int) | ||
| 1547 | case AUTOFS_IOC_SETTIMEOUT32: | ||
| 1548 | return ioc_settimeout(fd, cmd, argp); | ||
| 1549 | /* One SMB ioctl needs translations. */ | ||
| 1550 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | ||
| 1551 | case SMB_IOC_GETMOUNTUID_32: | ||
| 1552 | return do_smb_getmountuid(fd, cmd, argp); | ||
| 1553 | /* Serial */ | ||
| 1554 | case TIOCGSERIAL: | ||
| 1555 | case TIOCSSERIAL: | ||
| 1556 | return serial_struct_ioctl(fd, cmd, argp); | ||
| 1557 | /* i2c */ | ||
| 1558 | case I2C_FUNCS: | ||
| 1559 | return w_long(fd, cmd, argp); | ||
| 1560 | case I2C_RDWR: | ||
| 1561 | return do_i2c_rdwr_ioctl(fd, cmd, argp); | ||
| 1562 | case I2C_SMBUS: | ||
| 1563 | return do_i2c_smbus_ioctl(fd, cmd, argp); | ||
| 1564 | /* Not implemented in the native kernel */ | ||
| 1565 | case RTC_IRQP_READ32: | ||
| 1566 | case RTC_IRQP_SET32: | ||
| 1567 | case RTC_EPOCH_READ32: | ||
| 1568 | case RTC_EPOCH_SET32: | ||
| 1569 | return rtc_ioctl(fd, cmd, argp); | ||
| 1570 | |||
| 1571 | /* dvb */ | ||
| 1572 | case VIDEO_GET_EVENT: | ||
| 1573 | return do_video_get_event(fd, cmd, argp); | ||
| 1574 | case VIDEO_STILLPICTURE: | ||
| 1575 | return do_video_stillpicture(fd, cmd, argp); | ||
| 1576 | case VIDEO_SET_SPU_PALETTE: | ||
| 1577 | return do_video_set_spu_palette(fd, cmd, argp); | ||
| 1578 | } | ||
| 1579 | |||
| 1580 | /* | ||
| 1581 | * These take an integer instead of a pointer as 'arg', | ||
| 1582 | * so we must not do a compat_ptr() translation. | ||
| 1583 | */ | ||
| 1584 | switch (cmd) { | ||
| 1585 | /* Big T */ | ||
| 1586 | case TCSBRKP: | ||
| 1587 | case TIOCMIWAIT: | ||
| 1588 | case TIOCSCTTY: | ||
| 1589 | /* RAID */ | ||
| 1590 | case HOT_REMOVE_DISK: | ||
| 1591 | case HOT_ADD_DISK: | ||
| 1592 | case SET_DISK_FAULTY: | ||
| 1593 | case SET_BITMAP_FILE: | ||
| 1594 | /* Big K */ | ||
| 1595 | case KDSIGACCEPT: | ||
| 1596 | case KIOCSOUND: | ||
| 1597 | case KDMKTONE: | ||
| 1598 | case KDSETMODE: | ||
| 1599 | case KDSKBMODE: | ||
| 1600 | case KDSKBMETA: | ||
| 1601 | case KDSKBLED: | ||
| 1602 | case KDSETLED: | ||
| 1603 | /* SG stuff */ | ||
| 1604 | case SG_SET_TRANSFORM: | ||
| 1605 | /* AUTOFS */ | ||
| 1606 | case AUTOFS_IOC_READY: | ||
| 1607 | case AUTOFS_IOC_FAIL: | ||
| 1608 | /* NBD */ | ||
| 1609 | case NBD_SET_SOCK: | ||
| 1610 | case NBD_SET_BLKSIZE: | ||
| 1611 | case NBD_SET_SIZE: | ||
| 1612 | case NBD_SET_SIZE_BLOCKS: | ||
| 1613 | return do_vfs_ioctl(file, fd, cmd, arg); | ||
| 1614 | } | ||
| 1615 | |||
| 1616 | return -ENOIOCTLCMD; | ||
| 2736 | } | 1617 | } |
| 2737 | 1618 | ||
| 2738 | static void compat_ioctl_error(struct file *filp, unsigned int fd, | 1619 | static void compat_ioctl_error(struct file *filp, unsigned int fd, |
| @@ -2764,12 +1645,33 @@ static void compat_ioctl_error(struct file *filp, unsigned int fd, | |||
| 2764 | free_page((unsigned long)path); | 1645 | free_page((unsigned long)path); |
| 2765 | } | 1646 | } |
| 2766 | 1647 | ||
| 1648 | static int compat_ioctl_check_table(unsigned int xcmd) | ||
| 1649 | { | ||
| 1650 | int i; | ||
| 1651 | const int max = ARRAY_SIZE(ioctl_pointer) - 1; | ||
| 1652 | |||
| 1653 | BUILD_BUG_ON(max >= (1 << 16)); | ||
| 1654 | |||
| 1655 | /* guess initial offset into table, assuming a | ||
| 1656 | normalized distribution */ | ||
| 1657 | i = ((xcmd >> 16) * max) >> 16; | ||
| 1658 | |||
| 1659 | /* do linear search up first, until greater or equal */ | ||
| 1660 | while (ioctl_pointer[i] < xcmd && i < max) | ||
| 1661 | i++; | ||
| 1662 | |||
| 1663 | /* then do linear search down */ | ||
| 1664 | while (ioctl_pointer[i] > xcmd && i > 0) | ||
| 1665 | i--; | ||
| 1666 | |||
| 1667 | return ioctl_pointer[i] == xcmd; | ||
| 1668 | } | ||
| 1669 | |||
| 2767 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | 1670 | asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, |
| 2768 | unsigned long arg) | 1671 | unsigned long arg) |
| 2769 | { | 1672 | { |
| 2770 | struct file *filp; | 1673 | struct file *filp; |
| 2771 | int error = -EBADF; | 1674 | int error = -EBADF; |
| 2772 | struct ioctl_trans *t; | ||
| 2773 | int fput_needed; | 1675 | int fput_needed; |
| 2774 | 1676 | ||
| 2775 | filp = fget_light(fd, &fput_needed); | 1677 | filp = fget_light(fd, &fput_needed); |
| @@ -2797,7 +1699,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2797 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) | 1699 | #if defined(CONFIG_IA64) || defined(CONFIG_X86_64) |
| 2798 | case FS_IOC_RESVSP_32: | 1700 | case FS_IOC_RESVSP_32: |
| 2799 | case FS_IOC_RESVSP64_32: | 1701 | case FS_IOC_RESVSP64_32: |
| 2800 | error = compat_ioctl_preallocate(filp, arg); | 1702 | error = compat_ioctl_preallocate(filp, compat_ptr(arg)); |
| 2801 | goto out_fput; | 1703 | goto out_fput; |
| 2802 | #else | 1704 | #else |
| 2803 | case FS_IOC_RESVSP: | 1705 | case FS_IOC_RESVSP: |
| @@ -2826,18 +1728,11 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2826 | break; | 1728 | break; |
| 2827 | } | 1729 | } |
| 2828 | 1730 | ||
| 2829 | for (t = ioctl32_hash_table[ioctl32_hash(cmd)]; t; t = t->next) { | 1731 | if (compat_ioctl_check_table(XFORM(cmd))) |
| 2830 | if (t->cmd == cmd) | 1732 | goto found_handler; |
| 2831 | goto found_handler; | ||
| 2832 | } | ||
| 2833 | 1733 | ||
| 2834 | #ifdef CONFIG_NET | 1734 | error = do_ioctl_trans(fd, cmd, arg, filp); |
| 2835 | if (S_ISSOCK(filp->f_path.dentry->d_inode->i_mode) && | 1735 | if (error == -ENOIOCTLCMD) { |
| 2836 | cmd >= SIOCDEVPRIVATE && cmd <= (SIOCDEVPRIVATE + 15)) { | ||
| 2837 | error = siocdevprivate_ioctl(fd, cmd, arg); | ||
| 2838 | } else | ||
| 2839 | #endif | ||
| 2840 | { | ||
| 2841 | static int count; | 1736 | static int count; |
| 2842 | 1737 | ||
| 2843 | if (++count <= 50) | 1738 | if (++count <= 50) |
| @@ -2848,13 +1743,7 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2848 | goto out_fput; | 1743 | goto out_fput; |
| 2849 | 1744 | ||
| 2850 | found_handler: | 1745 | found_handler: |
| 2851 | if (t->handler) { | 1746 | arg = (unsigned long)compat_ptr(arg); |
| 2852 | lock_kernel(); | ||
| 2853 | error = t->handler(fd, cmd, arg, filp); | ||
| 2854 | unlock_kernel(); | ||
| 2855 | goto out_fput; | ||
| 2856 | } | ||
| 2857 | |||
| 2858 | do_ioctl: | 1747 | do_ioctl: |
| 2859 | error = do_vfs_ioctl(filp, fd, cmd, arg); | 1748 | error = do_vfs_ioctl(filp, fd, cmd, arg); |
| 2860 | out_fput: | 1749 | out_fput: |
| @@ -2863,35 +1752,22 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, | |||
| 2863 | return error; | 1752 | return error; |
| 2864 | } | 1753 | } |
| 2865 | 1754 | ||
| 2866 | static void ioctl32_insert_translation(struct ioctl_trans *trans) | 1755 | static int __init init_sys32_ioctl_cmp(const void *p, const void *q) |
| 2867 | { | 1756 | { |
| 2868 | unsigned long hash; | 1757 | unsigned int a, b; |
| 2869 | struct ioctl_trans *t; | 1758 | a = *(unsigned int *)p; |
| 2870 | 1759 | b = *(unsigned int *)q; | |
| 2871 | hash = ioctl32_hash (trans->cmd); | 1760 | if (a > b) |
| 2872 | if (!ioctl32_hash_table[hash]) | 1761 | return 1; |
| 2873 | ioctl32_hash_table[hash] = trans; | 1762 | if (a < b) |
| 2874 | else { | 1763 | return -1; |
| 2875 | t = ioctl32_hash_table[hash]; | 1764 | return 0; |
| 2876 | while (t->next) | ||
| 2877 | t = t->next; | ||
| 2878 | trans->next = NULL; | ||
| 2879 | t->next = trans; | ||
| 2880 | } | ||
| 2881 | } | 1765 | } |
| 2882 | 1766 | ||
| 2883 | static int __init init_sys32_ioctl(void) | 1767 | static int __init init_sys32_ioctl(void) |
| 2884 | { | 1768 | { |
| 2885 | int i; | 1769 | sort(ioctl_pointer, ARRAY_SIZE(ioctl_pointer), sizeof(*ioctl_pointer), |
| 2886 | 1770 | init_sys32_ioctl_cmp, NULL); | |
| 2887 | for (i = 0; i < ARRAY_SIZE(ioctl_start); i++) { | ||
| 2888 | if (ioctl_start[i].next) { | ||
| 2889 | printk("ioctl translation %d bad\n",i); | ||
| 2890 | return -1; | ||
| 2891 | } | ||
| 2892 | |||
| 2893 | ioctl32_insert_translation(&ioctl_start[i]); | ||
| 2894 | } | ||
| 2895 | return 0; | 1771 | return 0; |
| 2896 | } | 1772 | } |
| 2897 | __initcall(init_sys32_ioctl); | 1773 | __initcall(init_sys32_ioctl); |
