compat_ioctl.c 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  4. *
  5. * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
  6. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  7. * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
  8. * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz)
  9. *
  10. * These routines maintain argument size conversion between 32bit and 64bit
  11. * ioctls.
  12. */
  13. #include <linux/joystick.h>
  14. #include <linux/types.h>
  15. #include <linux/compat.h>
  16. #include <linux/kernel.h>
  17. #include <linux/capability.h>
  18. #include <linux/compiler.h>
  19. #include <linux/sched.h>
  20. #include <linux/smp.h>
  21. #include <linux/ioctl.h>
  22. #include <linux/if.h>
  23. #include <linux/raid/md_u.h>
  24. #include <linux/falloc.h>
  25. #include <linux/file.h>
  26. #include <linux/ppp-ioctl.h>
  27. #include <linux/if_pppox.h>
  28. #include <linux/mtio.h>
  29. #include <linux/tty.h>
  30. #include <linux/vt_kern.h>
  31. #include <linux/raw.h>
  32. #include <linux/blkdev.h>
  33. #include <linux/rtc.h>
  34. #include <linux/pci.h>
  35. #include <linux/serial.h>
  36. #include <linux/ctype.h>
  37. #include <linux/syscalls.h>
  38. #include <linux/gfp.h>
  39. #include <linux/cec.h>
  40. #include "internal.h"
  41. #include <net/bluetooth/bluetooth.h>
  42. #include <net/bluetooth/hci_sock.h>
  43. #include <net/bluetooth/rfcomm.h>
  44. #include <linux/capi.h>
  45. #include <linux/gigaset_dev.h>
  46. #ifdef CONFIG_BLOCK
  47. #include <linux/cdrom.h>
  48. #include <linux/fd.h>
  49. #include <scsi/scsi.h>
  50. #include <scsi/scsi_ioctl.h>
  51. #include <scsi/sg.h>
  52. #endif
  53. #include <linux/uaccess.h>
  54. #include <linux/watchdog.h>
  55. #include <linux/soundcard.h>
  56. #include <linux/hiddev.h>
  57. #include <linux/sort.h>
  58. #ifdef CONFIG_SPARC
  59. #include <linux/fb.h>
  60. #include <asm/fbio.h>
  61. #endif
  62. #define convert_in_user(srcptr, dstptr) \
  63. ({ \
  64. typeof(*srcptr) val; \
  65. \
  66. get_user(val, srcptr) || put_user(val, dstptr); \
  67. })
  68. static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  69. {
  70. int err;
  71. err = security_file_ioctl(file, cmd, arg);
  72. if (err)
  73. return err;
  74. return vfs_ioctl(file, cmd, arg);
  75. }
  76. #ifdef CONFIG_BLOCK
  77. typedef struct sg_io_hdr32 {
  78. compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
  79. compat_int_t dxfer_direction; /* [i] data transfer direction */
  80. unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
  81. unsigned char mx_sb_len; /* [i] max length to write to sbp */
  82. unsigned short iovec_count; /* [i] 0 implies no scatter gather */
  83. compat_uint_t dxfer_len; /* [i] byte count of data transfer */
  84. compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
  85. or scatter gather list */
  86. compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
  87. compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
  88. compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
  89. compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
  90. compat_int_t pack_id; /* [i->o] unused internally (normally) */
  91. compat_uptr_t usr_ptr; /* [i->o] unused internally */
  92. unsigned char status; /* [o] scsi status */
  93. unsigned char masked_status; /* [o] shifted, masked scsi status */
  94. unsigned char msg_status; /* [o] messaging level data (optional) */
  95. unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
  96. unsigned short host_status; /* [o] errors from host adapter */
  97. unsigned short driver_status; /* [o] errors from software driver */
  98. compat_int_t resid; /* [o] dxfer_len - actual_transferred */
  99. compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
  100. compat_uint_t info; /* [o] auxiliary information */
  101. } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
  102. typedef struct sg_iovec32 {
  103. compat_uint_t iov_base;
  104. compat_uint_t iov_len;
  105. } sg_iovec32_t;
  106. static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
  107. {
  108. sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
  109. sg_iovec32_t __user *iov32 = dxferp;
  110. int i;
  111. for (i = 0; i < iovec_count; i++) {
  112. u32 base, len;
  113. if (get_user(base, &iov32[i].iov_base) ||
  114. get_user(len, &iov32[i].iov_len) ||
  115. put_user(compat_ptr(base), &iov[i].iov_base) ||
  116. put_user(len, &iov[i].iov_len))
  117. return -EFAULT;
  118. }
  119. if (put_user(iov, &sgio->dxferp))
  120. return -EFAULT;
  121. return 0;
  122. }
  123. static int sg_ioctl_trans(struct file *file, unsigned int cmd,
  124. sg_io_hdr32_t __user *sgio32)
  125. {
  126. sg_io_hdr_t __user *sgio;
  127. u16 iovec_count;
  128. u32 data;
  129. void __user *dxferp;
  130. int err;
  131. int interface_id;
  132. if (get_user(interface_id, &sgio32->interface_id))
  133. return -EFAULT;
  134. if (interface_id != 'S')
  135. return do_ioctl(file, cmd, (unsigned long)sgio32);
  136. if (get_user(iovec_count, &sgio32->iovec_count))
  137. return -EFAULT;
  138. {
  139. void __user *top = compat_alloc_user_space(0);
  140. void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
  141. (iovec_count * sizeof(sg_iovec_t)));
  142. if (new > top)
  143. return -EINVAL;
  144. sgio = new;
  145. }
  146. /* Ok, now construct. */
  147. if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
  148. (2 * sizeof(int)) +
  149. (2 * sizeof(unsigned char)) +
  150. (1 * sizeof(unsigned short)) +
  151. (1 * sizeof(unsigned int))))
  152. return -EFAULT;
  153. if (get_user(data, &sgio32->dxferp))
  154. return -EFAULT;
  155. dxferp = compat_ptr(data);
  156. if (iovec_count) {
  157. if (sg_build_iovec(sgio, dxferp, iovec_count))
  158. return -EFAULT;
  159. } else {
  160. if (put_user(dxferp, &sgio->dxferp))
  161. return -EFAULT;
  162. }
  163. {
  164. unsigned char __user *cmdp;
  165. unsigned char __user *sbp;
  166. if (get_user(data, &sgio32->cmdp))
  167. return -EFAULT;
  168. cmdp = compat_ptr(data);
  169. if (get_user(data, &sgio32->sbp))
  170. return -EFAULT;
  171. sbp = compat_ptr(data);
  172. if (put_user(cmdp, &sgio->cmdp) ||
  173. put_user(sbp, &sgio->sbp))
  174. return -EFAULT;
  175. }
  176. if (copy_in_user(&sgio->timeout, &sgio32->timeout,
  177. 3 * sizeof(int)))
  178. return -EFAULT;
  179. if (get_user(data, &sgio32->usr_ptr))
  180. return -EFAULT;
  181. if (put_user(compat_ptr(data), &sgio->usr_ptr))
  182. return -EFAULT;
  183. err = do_ioctl(file, cmd, (unsigned long) sgio);
  184. if (err >= 0) {
  185. void __user *datap;
  186. if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
  187. sizeof(int)) ||
  188. get_user(datap, &sgio->usr_ptr) ||
  189. put_user((u32)(unsigned long)datap,
  190. &sgio32->usr_ptr) ||
  191. copy_in_user(&sgio32->status, &sgio->status,
  192. (4 * sizeof(unsigned char)) +
  193. (2 * sizeof(unsigned short)) +
  194. (3 * sizeof(int))))
  195. err = -EFAULT;
  196. }
  197. return err;
  198. }
  199. struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
  200. char req_state;
  201. char orphan;
  202. char sg_io_owned;
  203. char problem;
  204. int pack_id;
  205. compat_uptr_t usr_ptr;
  206. unsigned int duration;
  207. int unused;
  208. };
  209. static int sg_grt_trans(struct file *file,
  210. unsigned int cmd, struct compat_sg_req_info __user *o)
  211. {
  212. int err, i;
  213. sg_req_info_t __user *r;
  214. r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
  215. err = do_ioctl(file, cmd, (unsigned long)r);
  216. if (err < 0)
  217. return err;
  218. for (i = 0; i < SG_MAX_QUEUE; i++) {
  219. void __user *ptr;
  220. int d;
  221. if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
  222. get_user(ptr, &r[i].usr_ptr) ||
  223. get_user(d, &r[i].duration) ||
  224. put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
  225. put_user(d, &o[i].duration))
  226. return -EFAULT;
  227. }
  228. return err;
  229. }
  230. #endif /* CONFIG_BLOCK */
  231. struct sock_fprog32 {
  232. unsigned short len;
  233. compat_caddr_t filter;
  234. };
  235. #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
  236. #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
  237. static int ppp_sock_fprog_ioctl_trans(struct file *file,
  238. unsigned int cmd, struct sock_fprog32 __user *u_fprog32)
  239. {
  240. struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
  241. void __user *fptr64;
  242. u32 fptr32;
  243. u16 flen;
  244. if (get_user(flen, &u_fprog32->len) ||
  245. get_user(fptr32, &u_fprog32->filter))
  246. return -EFAULT;
  247. fptr64 = compat_ptr(fptr32);
  248. if (put_user(flen, &u_fprog64->len) ||
  249. put_user(fptr64, &u_fprog64->filter))
  250. return -EFAULT;
  251. if (cmd == PPPIOCSPASS32)
  252. cmd = PPPIOCSPASS;
  253. else
  254. cmd = PPPIOCSACTIVE;
  255. return do_ioctl(file, cmd, (unsigned long) u_fprog64);
  256. }
  257. struct ppp_option_data32 {
  258. compat_caddr_t ptr;
  259. u32 length;
  260. compat_int_t transmit;
  261. };
  262. #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
  263. struct ppp_idle32 {
  264. compat_time_t xmit_idle;
  265. compat_time_t recv_idle;
  266. };
  267. #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
  268. static int ppp_gidle(struct file *file, unsigned int cmd,
  269. struct ppp_idle32 __user *idle32)
  270. {
  271. struct ppp_idle __user *idle;
  272. __kernel_time_t xmit, recv;
  273. int err;
  274. idle = compat_alloc_user_space(sizeof(*idle));
  275. err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle);
  276. if (!err) {
  277. if (get_user(xmit, &idle->xmit_idle) ||
  278. get_user(recv, &idle->recv_idle) ||
  279. put_user(xmit, &idle32->xmit_idle) ||
  280. put_user(recv, &idle32->recv_idle))
  281. err = -EFAULT;
  282. }
  283. return err;
  284. }
  285. static int ppp_scompress(struct file *file, unsigned int cmd,
  286. struct ppp_option_data32 __user *odata32)
  287. {
  288. struct ppp_option_data __user *odata;
  289. __u32 data;
  290. void __user *datap;
  291. odata = compat_alloc_user_space(sizeof(*odata));
  292. if (get_user(data, &odata32->ptr))
  293. return -EFAULT;
  294. datap = compat_ptr(data);
  295. if (put_user(datap, &odata->ptr))
  296. return -EFAULT;
  297. if (copy_in_user(&odata->length, &odata32->length,
  298. sizeof(__u32) + sizeof(int)))
  299. return -EFAULT;
  300. return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata);
  301. }
  302. #ifdef CONFIG_BLOCK
  303. struct mtget32 {
  304. compat_long_t mt_type;
  305. compat_long_t mt_resid;
  306. compat_long_t mt_dsreg;
  307. compat_long_t mt_gstat;
  308. compat_long_t mt_erreg;
  309. compat_daddr_t mt_fileno;
  310. compat_daddr_t mt_blkno;
  311. };
  312. #define MTIOCGET32 _IOR('m', 2, struct mtget32)
  313. struct mtpos32 {
  314. compat_long_t mt_blkno;
  315. };
  316. #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
  317. static int mt_ioctl_trans(struct file *file,
  318. unsigned int cmd, void __user *argp)
  319. {
  320. /* NULL initialization to make gcc shut up */
  321. struct mtget __user *get = NULL;
  322. struct mtget32 __user *umget32;
  323. struct mtpos __user *pos = NULL;
  324. struct mtpos32 __user *upos32;
  325. unsigned long kcmd;
  326. void *karg;
  327. int err = 0;
  328. switch(cmd) {
  329. case MTIOCPOS32:
  330. kcmd = MTIOCPOS;
  331. pos = compat_alloc_user_space(sizeof(*pos));
  332. karg = pos;
  333. break;
  334. default: /* MTIOCGET32 */
  335. kcmd = MTIOCGET;
  336. get = compat_alloc_user_space(sizeof(*get));
  337. karg = get;
  338. break;
  339. }
  340. if (karg == NULL)
  341. return -EFAULT;
  342. err = do_ioctl(file, kcmd, (unsigned long)karg);
  343. if (err)
  344. return err;
  345. switch (cmd) {
  346. case MTIOCPOS32:
  347. upos32 = argp;
  348. err = convert_in_user(&pos->mt_blkno, &upos32->mt_blkno);
  349. break;
  350. case MTIOCGET32:
  351. umget32 = argp;
  352. err = convert_in_user(&get->mt_type, &umget32->mt_type);
  353. err |= convert_in_user(&get->mt_resid, &umget32->mt_resid);
  354. err |= convert_in_user(&get->mt_dsreg, &umget32->mt_dsreg);
  355. err |= convert_in_user(&get->mt_gstat, &umget32->mt_gstat);
  356. err |= convert_in_user(&get->mt_erreg, &umget32->mt_erreg);
  357. err |= convert_in_user(&get->mt_fileno, &umget32->mt_fileno);
  358. err |= convert_in_user(&get->mt_blkno, &umget32->mt_blkno);
  359. break;
  360. }
  361. return err ? -EFAULT: 0;
  362. }
  363. #endif /* CONFIG_BLOCK */
  364. /* Bluetooth ioctls */
  365. #define HCIUARTSETPROTO _IOW('U', 200, int)
  366. #define HCIUARTGETPROTO _IOR('U', 201, int)
  367. #define HCIUARTGETDEVICE _IOR('U', 202, int)
  368. #define HCIUARTSETFLAGS _IOW('U', 203, int)
  369. #define HCIUARTGETFLAGS _IOR('U', 204, int)
  370. #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
  371. #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
  372. #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
  373. #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
  374. static int rtc_ioctl(struct file *file,
  375. unsigned cmd, void __user *argp)
  376. {
  377. unsigned long __user *valp = compat_alloc_user_space(sizeof(*valp));
  378. int ret;
  379. if (valp == NULL)
  380. return -EFAULT;
  381. switch (cmd) {
  382. case RTC_IRQP_READ32:
  383. case RTC_EPOCH_READ32:
  384. ret = do_ioctl(file, (cmd == RTC_IRQP_READ32) ?
  385. RTC_IRQP_READ : RTC_EPOCH_READ,
  386. (unsigned long)valp);
  387. if (ret)
  388. return ret;
  389. return convert_in_user(valp, (unsigned int __user *)argp);
  390. case RTC_IRQP_SET32:
  391. return do_ioctl(file, RTC_IRQP_SET, (unsigned long)argp);
  392. case RTC_EPOCH_SET32:
  393. return do_ioctl(file, RTC_EPOCH_SET, (unsigned long)argp);
  394. }
  395. return -ENOIOCTLCMD;
  396. }
  397. /* on ia32 l_start is on a 32-bit boundary */
  398. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  399. struct space_resv_32 {
  400. __s16 l_type;
  401. __s16 l_whence;
  402. __s64 l_start __attribute__((packed));
  403. /* len == 0 means until end of file */
  404. __s64 l_len __attribute__((packed));
  405. __s32 l_sysid;
  406. __u32 l_pid;
  407. __s32 l_pad[4]; /* reserve area */
  408. };
  409. #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
  410. #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
  411. /* just account for different alignment */
  412. static int compat_ioctl_preallocate(struct file *file,
  413. struct space_resv_32 __user *p32)
  414. {
  415. struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
  416. if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
  417. copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
  418. copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
  419. copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
  420. copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
  421. copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
  422. copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
  423. return -EFAULT;
  424. return ioctl_preallocate(file, p);
  425. }
  426. #endif
  427. /*
  428. * simple reversible transform to make our table more evenly
  429. * distributed after sorting.
  430. */
  431. #define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0xffffffff)
  432. #define COMPATIBLE_IOCTL(cmd) XFORM((u32)cmd),
  433. /* ioctl should not be warned about even if it's not implemented.
  434. Valid reasons to use this:
  435. - It is implemented with ->compat_ioctl on some device, but programs
  436. call it on others too.
  437. - The ioctl is not implemented in the native kernel, but programs
  438. call it commonly anyways.
  439. Most other reasons are not valid. */
  440. #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
  441. static unsigned int ioctl_pointer[] = {
  442. /* compatible ioctls first */
  443. /* Little t */
  444. COMPATIBLE_IOCTL(TIOCOUTQ)
  445. /* Little f */
  446. COMPATIBLE_IOCTL(FIOCLEX)
  447. COMPATIBLE_IOCTL(FIONCLEX)
  448. COMPATIBLE_IOCTL(FIOASYNC)
  449. COMPATIBLE_IOCTL(FIONBIO)
  450. COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
  451. COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
  452. /* 0x00 */
  453. COMPATIBLE_IOCTL(FIBMAP)
  454. COMPATIBLE_IOCTL(FIGETBSZ)
  455. /* 'X' - originally XFS but some now in the VFS */
  456. COMPATIBLE_IOCTL(FIFREEZE)
  457. COMPATIBLE_IOCTL(FITHAW)
  458. COMPATIBLE_IOCTL(FITRIM)
  459. #ifdef CONFIG_BLOCK
  460. /* Big S */
  461. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
  462. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
  463. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
  464. COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
  465. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
  466. COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
  467. COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
  468. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
  469. #endif
  470. /* Big V (don't complain on serial console) */
  471. IGNORE_IOCTL(VT_OPENQRY)
  472. IGNORE_IOCTL(VT_GETMODE)
  473. /* Little p (/dev/rtc, /dev/envctrl, etc.) */
  474. COMPATIBLE_IOCTL(RTC_AIE_ON)
  475. COMPATIBLE_IOCTL(RTC_AIE_OFF)
  476. COMPATIBLE_IOCTL(RTC_UIE_ON)
  477. COMPATIBLE_IOCTL(RTC_UIE_OFF)
  478. COMPATIBLE_IOCTL(RTC_PIE_ON)
  479. COMPATIBLE_IOCTL(RTC_PIE_OFF)
  480. COMPATIBLE_IOCTL(RTC_WIE_ON)
  481. COMPATIBLE_IOCTL(RTC_WIE_OFF)
  482. COMPATIBLE_IOCTL(RTC_ALM_SET)
  483. COMPATIBLE_IOCTL(RTC_ALM_READ)
  484. COMPATIBLE_IOCTL(RTC_RD_TIME)
  485. COMPATIBLE_IOCTL(RTC_SET_TIME)
  486. COMPATIBLE_IOCTL(RTC_WKALM_SET)
  487. COMPATIBLE_IOCTL(RTC_WKALM_RD)
  488. /*
  489. * These two are only for the sbus rtc driver, but
  490. * hwclock tries them on every rtc device first when
  491. * running on sparc. On other architectures the entries
  492. * are useless but harmless.
  493. */
  494. COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
  495. COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
  496. /* Little m */
  497. COMPATIBLE_IOCTL(MTIOCTOP)
  498. /* Socket level stuff */
  499. COMPATIBLE_IOCTL(FIOQSIZE)
  500. #ifdef CONFIG_BLOCK
  501. /* md calls this on random blockdevs */
  502. IGNORE_IOCTL(RAID_VERSION)
  503. /* qemu/qemu-img might call these two on plain files for probing */
  504. IGNORE_IOCTL(CDROM_DRIVE_STATUS)
  505. IGNORE_IOCTL(FDGETPRM32)
  506. /* SG stuff */
  507. COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
  508. COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
  509. COMPATIBLE_IOCTL(SG_EMULATED_HOST)
  510. COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
  511. COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
  512. COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
  513. COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
  514. COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
  515. COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
  516. COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
  517. COMPATIBLE_IOCTL(SG_GET_PACK_ID)
  518. COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
  519. COMPATIBLE_IOCTL(SG_SET_DEBUG)
  520. COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
  521. COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
  522. COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
  523. COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
  524. COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
  525. COMPATIBLE_IOCTL(SG_SCSI_RESET)
  526. COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
  527. COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
  528. COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
  529. #endif
  530. /* PPP stuff */
  531. COMPATIBLE_IOCTL(PPPIOCGFLAGS)
  532. COMPATIBLE_IOCTL(PPPIOCSFLAGS)
  533. COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
  534. COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
  535. COMPATIBLE_IOCTL(PPPIOCGUNIT)
  536. COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
  537. COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
  538. COMPATIBLE_IOCTL(PPPIOCGMRU)
  539. COMPATIBLE_IOCTL(PPPIOCSMRU)
  540. COMPATIBLE_IOCTL(PPPIOCSMAXCID)
  541. COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
  542. COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
  543. COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
  544. /* PPPIOCSCOMPRESS is translated */
  545. COMPATIBLE_IOCTL(PPPIOCGNPMODE)
  546. COMPATIBLE_IOCTL(PPPIOCSNPMODE)
  547. COMPATIBLE_IOCTL(PPPIOCGDEBUG)
  548. COMPATIBLE_IOCTL(PPPIOCSDEBUG)
  549. /* PPPIOCSPASS is translated */
  550. /* PPPIOCSACTIVE is translated */
  551. /* PPPIOCGIDLE is translated */
  552. COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
  553. COMPATIBLE_IOCTL(PPPIOCATTACH)
  554. COMPATIBLE_IOCTL(PPPIOCDETACH)
  555. COMPATIBLE_IOCTL(PPPIOCSMRRU)
  556. COMPATIBLE_IOCTL(PPPIOCCONNECT)
  557. COMPATIBLE_IOCTL(PPPIOCDISCONN)
  558. COMPATIBLE_IOCTL(PPPIOCATTCHAN)
  559. COMPATIBLE_IOCTL(PPPIOCGCHAN)
  560. COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS)
  561. /* PPPOX */
  562. COMPATIBLE_IOCTL(PPPOEIOCSFWD)
  563. COMPATIBLE_IOCTL(PPPOEIOCDFWD)
  564. /* Big A */
  565. /* sparc only */
  566. /* Big Q for sound/OSS */
  567. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
  568. COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
  569. COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
  570. COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
  571. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
  572. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
  573. COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
  574. COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
  575. COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
  576. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
  577. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
  578. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
  579. COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
  580. COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
  581. COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
  582. COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
  583. COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
  584. COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
  585. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
  586. COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
  587. COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
  588. COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
  589. /* Big T for sound/OSS */
  590. COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
  591. COMPATIBLE_IOCTL(SNDCTL_TMR_START)
  592. COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
  593. COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
  594. COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
  595. COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
  596. COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
  597. COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
  598. /* Little m for sound/OSS */
  599. COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
  600. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
  601. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
  602. /* Big P for sound/OSS */
  603. COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
  604. COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
  605. COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
  606. COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
  607. COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
  608. COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
  609. COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
  610. COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
  611. COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
  612. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
  613. COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
  614. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
  615. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
  616. COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
  617. COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
  618. COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
  619. COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
  620. COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
  621. COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
  622. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
  623. /* SNDCTL_DSP_MAPINBUF, XXX needs translation */
  624. /* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
  625. COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
  626. COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
  627. COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
  628. COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
  629. COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
  630. COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
  631. COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
  632. COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
  633. /* Big C for sound/OSS */
  634. COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
  635. COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
  636. COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
  637. COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
  638. COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
  639. COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
  640. COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
  641. COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
  642. COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
  643. COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
  644. /* Big M for sound/OSS */
  645. COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
  646. COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
  647. COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
  648. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
  649. COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
  650. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
  651. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
  652. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
  653. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
  654. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
  655. COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
  656. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
  657. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
  658. COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
  659. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
  660. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
  661. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
  662. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
  663. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
  664. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
  665. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
  666. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
  667. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
  668. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
  669. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
  670. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
  671. /* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
  672. /* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
  673. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
  674. COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
  675. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
  676. COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
  677. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
  678. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
  679. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
  680. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
  681. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
  682. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
  683. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
  684. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
  685. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
  686. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
  687. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
  688. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
  689. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
  690. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
  691. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
  692. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
  693. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
  694. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
  695. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
  696. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
  697. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
  698. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
  699. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
  700. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
  701. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
  702. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
  703. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
  704. /* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
  705. /* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
  706. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
  707. COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
  708. COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
  709. COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
  710. COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
  711. COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
  712. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
  713. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
  714. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
  715. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
  716. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
  717. COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
  718. COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
  719. COMPATIBLE_IOCTL(OSS_GETVERSION)
  720. /* Raw devices */
  721. COMPATIBLE_IOCTL(RAW_SETBIND)
  722. COMPATIBLE_IOCTL(RAW_GETBIND)
  723. /* Watchdog */
  724. COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
  725. COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
  726. COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
  727. COMPATIBLE_IOCTL(WDIOC_GETTEMP)
  728. COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
  729. COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
  730. COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
  731. COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
  732. COMPATIBLE_IOCTL(WDIOC_SETPRETIMEOUT)
  733. COMPATIBLE_IOCTL(WDIOC_GETPRETIMEOUT)
  734. /* Big R */
  735. COMPATIBLE_IOCTL(RNDGETENTCNT)
  736. COMPATIBLE_IOCTL(RNDADDTOENTCNT)
  737. COMPATIBLE_IOCTL(RNDGETPOOL)
  738. COMPATIBLE_IOCTL(RNDADDENTROPY)
  739. COMPATIBLE_IOCTL(RNDZAPENTCNT)
  740. COMPATIBLE_IOCTL(RNDCLEARPOOL)
  741. /* Bluetooth */
  742. COMPATIBLE_IOCTL(HCIDEVUP)
  743. COMPATIBLE_IOCTL(HCIDEVDOWN)
  744. COMPATIBLE_IOCTL(HCIDEVRESET)
  745. COMPATIBLE_IOCTL(HCIDEVRESTAT)
  746. COMPATIBLE_IOCTL(HCIGETDEVLIST)
  747. COMPATIBLE_IOCTL(HCIGETDEVINFO)
  748. COMPATIBLE_IOCTL(HCIGETCONNLIST)
  749. COMPATIBLE_IOCTL(HCIGETCONNINFO)
  750. COMPATIBLE_IOCTL(HCIGETAUTHINFO)
  751. COMPATIBLE_IOCTL(HCISETRAW)
  752. COMPATIBLE_IOCTL(HCISETSCAN)
  753. COMPATIBLE_IOCTL(HCISETAUTH)
  754. COMPATIBLE_IOCTL(HCISETENCRYPT)
  755. COMPATIBLE_IOCTL(HCISETPTYPE)
  756. COMPATIBLE_IOCTL(HCISETLINKPOL)
  757. COMPATIBLE_IOCTL(HCISETLINKMODE)
  758. COMPATIBLE_IOCTL(HCISETACLMTU)
  759. COMPATIBLE_IOCTL(HCISETSCOMTU)
  760. COMPATIBLE_IOCTL(HCIBLOCKADDR)
  761. COMPATIBLE_IOCTL(HCIUNBLOCKADDR)
  762. COMPATIBLE_IOCTL(HCIINQUIRY)
  763. COMPATIBLE_IOCTL(HCIUARTSETPROTO)
  764. COMPATIBLE_IOCTL(HCIUARTGETPROTO)
  765. COMPATIBLE_IOCTL(HCIUARTGETDEVICE)
  766. COMPATIBLE_IOCTL(HCIUARTSETFLAGS)
  767. COMPATIBLE_IOCTL(HCIUARTGETFLAGS)
  768. COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
  769. COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
  770. COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
  771. COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
  772. COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
  773. /* CAPI */
  774. COMPATIBLE_IOCTL(CAPI_REGISTER)
  775. COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
  776. COMPATIBLE_IOCTL(CAPI_GET_VERSION)
  777. COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
  778. COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
  779. COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
  780. COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
  781. COMPATIBLE_IOCTL(CAPI_INSTALLED)
  782. COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
  783. COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
  784. COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
  785. COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
  786. COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
  787. /* Misc. */
  788. COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
  789. COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
  790. COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
  791. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
  792. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
  793. COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
  794. /* hiddev */
  795. COMPATIBLE_IOCTL(HIDIOCGVERSION)
  796. COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
  797. COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
  798. COMPATIBLE_IOCTL(HIDIOCGSTRING)
  799. COMPATIBLE_IOCTL(HIDIOCINITREPORT)
  800. COMPATIBLE_IOCTL(HIDIOCGREPORT)
  801. COMPATIBLE_IOCTL(HIDIOCSREPORT)
  802. COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
  803. COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
  804. COMPATIBLE_IOCTL(HIDIOCGUSAGE)
  805. COMPATIBLE_IOCTL(HIDIOCSUSAGE)
  806. COMPATIBLE_IOCTL(HIDIOCGUCODE)
  807. COMPATIBLE_IOCTL(HIDIOCGFLAG)
  808. COMPATIBLE_IOCTL(HIDIOCSFLAG)
  809. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
  810. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
  811. /* joystick */
  812. COMPATIBLE_IOCTL(JSIOCGVERSION)
  813. COMPATIBLE_IOCTL(JSIOCGAXES)
  814. COMPATIBLE_IOCTL(JSIOCGBUTTONS)
  815. COMPATIBLE_IOCTL(JSIOCGNAME(0))
  816. /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
  817. but we don't want warnings on other file systems. So declare
  818. them as compatible here. */
  819. #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
  820. #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
  821. IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
  822. IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
  823. #ifdef CONFIG_SPARC
  824. /* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
  825. IGNORE_IOCTL(FBIOGTYPE)
  826. IGNORE_IOCTL(FBIOSATTR)
  827. IGNORE_IOCTL(FBIOGATTR)
  828. IGNORE_IOCTL(FBIOSVIDEO)
  829. IGNORE_IOCTL(FBIOGVIDEO)
  830. IGNORE_IOCTL(FBIOSCURPOS)
  831. IGNORE_IOCTL(FBIOGCURPOS)
  832. IGNORE_IOCTL(FBIOGCURMAX)
  833. IGNORE_IOCTL(FBIOPUTCMAP32)
  834. IGNORE_IOCTL(FBIOGETCMAP32)
  835. IGNORE_IOCTL(FBIOSCURSOR32)
  836. IGNORE_IOCTL(FBIOGCURSOR32)
  837. #endif
  838. };
  839. /*
  840. * Convert common ioctl arguments based on their command number
  841. *
  842. * Please do not add any code in here. Instead, implement
  843. * a compat_ioctl operation in the place that handleѕ the
  844. * ioctl for the native case.
  845. */
  846. static long do_ioctl_trans(unsigned int cmd,
  847. unsigned long arg, struct file *file)
  848. {
  849. void __user *argp = compat_ptr(arg);
  850. switch (cmd) {
  851. case PPPIOCGIDLE32:
  852. return ppp_gidle(file, cmd, argp);
  853. case PPPIOCSCOMPRESS32:
  854. return ppp_scompress(file, cmd, argp);
  855. case PPPIOCSPASS32:
  856. case PPPIOCSACTIVE32:
  857. return ppp_sock_fprog_ioctl_trans(file, cmd, argp);
  858. #ifdef CONFIG_BLOCK
  859. case SG_IO:
  860. return sg_ioctl_trans(file, cmd, argp);
  861. case SG_GET_REQUEST_TABLE:
  862. return sg_grt_trans(file, cmd, argp);
  863. case MTIOCGET32:
  864. case MTIOCPOS32:
  865. return mt_ioctl_trans(file, cmd, argp);
  866. #endif
  867. /* Not implemented in the native kernel */
  868. case RTC_IRQP_READ32:
  869. case RTC_IRQP_SET32:
  870. case RTC_EPOCH_READ32:
  871. case RTC_EPOCH_SET32:
  872. return rtc_ioctl(file, cmd, argp);
  873. }
  874. /*
  875. * These take an integer instead of a pointer as 'arg',
  876. * so we must not do a compat_ptr() translation.
  877. */
  878. switch (cmd) {
  879. /* RAID */
  880. case HOT_REMOVE_DISK:
  881. case HOT_ADD_DISK:
  882. case SET_DISK_FAULTY:
  883. case SET_BITMAP_FILE:
  884. return vfs_ioctl(file, cmd, arg);
  885. }
  886. return -ENOIOCTLCMD;
  887. }
  888. static int compat_ioctl_check_table(unsigned int xcmd)
  889. {
  890. int i;
  891. const int max = ARRAY_SIZE(ioctl_pointer) - 1;
  892. BUILD_BUG_ON(max >= (1 << 16));
  893. /* guess initial offset into table, assuming a
  894. normalized distribution */
  895. i = ((xcmd >> 16) * max) >> 16;
  896. /* do linear search up first, until greater or equal */
  897. while (ioctl_pointer[i] < xcmd && i < max)
  898. i++;
  899. /* then do linear search down */
  900. while (ioctl_pointer[i] > xcmd && i > 0)
  901. i--;
  902. return ioctl_pointer[i] == xcmd;
  903. }
  904. COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
  905. compat_ulong_t, arg32)
  906. {
  907. unsigned long arg = arg32;
  908. struct fd f = fdget(fd);
  909. int error = -EBADF;
  910. if (!f.file)
  911. goto out;
  912. /* RED-PEN how should LSM module know it's handling 32bit? */
  913. error = security_file_ioctl(f.file, cmd, arg);
  914. if (error)
  915. goto out_fput;
  916. /*
  917. * To allow the compat_ioctl handlers to be self contained
  918. * we need to check the common ioctls here first.
  919. * Just handle them with the standard handlers below.
  920. */
  921. switch (cmd) {
  922. case FIOCLEX:
  923. case FIONCLEX:
  924. case FIONBIO:
  925. case FIOASYNC:
  926. case FIOQSIZE:
  927. break;
  928. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  929. case FS_IOC_RESVSP_32:
  930. case FS_IOC_RESVSP64_32:
  931. error = compat_ioctl_preallocate(f.file, compat_ptr(arg));
  932. goto out_fput;
  933. #else
  934. case FS_IOC_RESVSP:
  935. case FS_IOC_RESVSP64:
  936. error = ioctl_preallocate(f.file, compat_ptr(arg));
  937. goto out_fput;
  938. #endif
  939. case FICLONE:
  940. case FICLONERANGE:
  941. case FIDEDUPERANGE:
  942. case FS_IOC_FIEMAP:
  943. goto do_ioctl;
  944. case FIBMAP:
  945. case FIGETBSZ:
  946. case FIONREAD:
  947. if (S_ISREG(file_inode(f.file)->i_mode))
  948. break;
  949. /*FALL THROUGH*/
  950. default:
  951. if (f.file->f_op->compat_ioctl) {
  952. error = f.file->f_op->compat_ioctl(f.file, cmd, arg);
  953. if (error != -ENOIOCTLCMD)
  954. goto out_fput;
  955. }
  956. if (!f.file->f_op->unlocked_ioctl)
  957. goto do_ioctl;
  958. break;
  959. }
  960. if (compat_ioctl_check_table(XFORM(cmd)))
  961. goto found_handler;
  962. error = do_ioctl_trans(cmd, arg, f.file);
  963. if (error == -ENOIOCTLCMD)
  964. error = -ENOTTY;
  965. goto out_fput;
  966. found_handler:
  967. arg = (unsigned long)compat_ptr(arg);
  968. do_ioctl:
  969. error = do_vfs_ioctl(f.file, fd, cmd, arg);
  970. out_fput:
  971. fdput(f);
  972. out:
  973. return error;
  974. }
  975. static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
  976. {
  977. unsigned int a, b;
  978. a = *(unsigned int *)p;
  979. b = *(unsigned int *)q;
  980. if (a > b)
  981. return 1;
  982. if (a < b)
  983. return -1;
  984. return 0;
  985. }
  986. static int __init init_sys32_ioctl(void)
  987. {
  988. sort(ioctl_pointer, ARRAY_SIZE(ioctl_pointer), sizeof(*ioctl_pointer),
  989. init_sys32_ioctl_cmp, NULL);
  990. return 0;
  991. }
  992. __initcall(init_sys32_ioctl);