compat_ioctl.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  1. /*
  2. * ioctl32.c: Conversion between 32bit and 64bit native ioctls.
  3. *
  4. * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com)
  5. * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be)
  6. * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs
  7. * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz)
  8. *
  9. * These routines maintain argument size conversion between 32bit and 64bit
  10. * ioctls.
  11. */
  12. #include <linux/joystick.h>
  13. #include <linux/types.h>
  14. #include <linux/compat.h>
  15. #include <linux/kernel.h>
  16. #include <linux/capability.h>
  17. #include <linux/compiler.h>
  18. #include <linux/sched.h>
  19. #include <linux/smp.h>
  20. #include <linux/ioctl.h>
  21. #include <linux/if.h>
  22. #include <linux/if_bridge.h>
  23. #include <linux/raid/md_u.h>
  24. #include <linux/kd.h>
  25. #include <linux/route.h>
  26. #include <linux/in6.h>
  27. #include <linux/ipv6_route.h>
  28. #include <linux/skbuff.h>
  29. #include <linux/netlink.h>
  30. #include <linux/vt.h>
  31. #include <linux/falloc.h>
  32. #include <linux/fs.h>
  33. #include <linux/file.h>
  34. #include <linux/ppp_defs.h>
  35. #include <linux/ppp-ioctl.h>
  36. #include <linux/if_pppox.h>
  37. #include <linux/mtio.h>
  38. #include <linux/auto_fs.h>
  39. #include <linux/auto_fs4.h>
  40. #include <linux/tty.h>
  41. #include <linux/vt_kern.h>
  42. #include <linux/fb.h>
  43. #include <linux/videodev2.h>
  44. #include <linux/netdevice.h>
  45. #include <linux/raw.h>
  46. #include <linux/blkdev.h>
  47. #include <linux/elevator.h>
  48. #include <linux/rtc.h>
  49. #include <linux/pci.h>
  50. #include <linux/serial.h>
  51. #include <linux/if_tun.h>
  52. #include <linux/ctype.h>
  53. #include <linux/syscalls.h>
  54. #include <linux/i2c.h>
  55. #include <linux/i2c-dev.h>
  56. #include <linux/atalk.h>
  57. #include <linux/gfp.h>
  58. #include "internal.h"
  59. #include <net/bluetooth/bluetooth.h>
  60. #include <net/bluetooth/hci_sock.h>
  61. #include <net/bluetooth/rfcomm.h>
  62. #include <linux/capi.h>
  63. #include <linux/gigaset_dev.h>
  64. #ifdef CONFIG_BLOCK
  65. #include <linux/cdrom.h>
  66. #include <linux/fd.h>
  67. #include <scsi/scsi.h>
  68. #include <scsi/scsi_ioctl.h>
  69. #include <scsi/sg.h>
  70. #endif
  71. #include <asm/uaccess.h>
  72. #include <linux/ethtool.h>
  73. #include <linux/mii.h>
  74. #include <linux/if_bonding.h>
  75. #include <linux/watchdog.h>
  76. #include <linux/soundcard.h>
  77. #include <linux/lp.h>
  78. #include <linux/ppdev.h>
  79. #include <linux/atm.h>
  80. #include <linux/atmarp.h>
  81. #include <linux/atmclip.h>
  82. #include <linux/atmdev.h>
  83. #include <linux/atmioc.h>
  84. #include <linux/atmlec.h>
  85. #include <linux/atmmpc.h>
  86. #include <linux/atmsvc.h>
  87. #include <linux/atm_tcp.h>
  88. #include <linux/sonet.h>
  89. #include <linux/atm_suni.h>
  90. #include <linux/usb.h>
  91. #include <linux/usbdevice_fs.h>
  92. #include <linux/nbd.h>
  93. #include <linux/random.h>
  94. #include <linux/filter.h>
  95. #include <linux/hiddev.h>
  96. #define __DVB_CORE__
  97. #include <linux/dvb/audio.h>
  98. #include <linux/dvb/dmx.h>
  99. #include <linux/dvb/frontend.h>
  100. #include <linux/dvb/video.h>
  101. #include <linux/sort.h>
  102. #ifdef CONFIG_SPARC
  103. #include <asm/fbio.h>
  104. #endif
  105. #define convert_in_user(srcptr, dstptr) \
  106. ({ \
  107. typeof(*srcptr) val; \
  108. \
  109. get_user(val, srcptr) || put_user(val, dstptr); \
  110. })
  111. static int do_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  112. {
  113. int err;
  114. err = security_file_ioctl(file, cmd, arg);
  115. if (err)
  116. return err;
  117. return vfs_ioctl(file, cmd, arg);
  118. }
  119. static int w_long(struct file *file,
  120. unsigned int cmd, compat_ulong_t __user *argp)
  121. {
  122. int err;
  123. unsigned long __user *valp = compat_alloc_user_space(sizeof(*valp));
  124. if (valp == NULL)
  125. return -EFAULT;
  126. err = do_ioctl(file, cmd, (unsigned long)valp);
  127. if (err)
  128. return err;
  129. if (convert_in_user(valp, argp))
  130. return -EFAULT;
  131. return 0;
  132. }
  133. struct compat_video_event {
  134. int32_t type;
  135. compat_time_t timestamp;
  136. union {
  137. video_size_t size;
  138. unsigned int frame_rate;
  139. } u;
  140. };
  141. static int do_video_get_event(struct file *file,
  142. unsigned int cmd, struct compat_video_event __user *up)
  143. {
  144. struct video_event __user *kevent =
  145. compat_alloc_user_space(sizeof(*kevent));
  146. int err;
  147. if (kevent == NULL)
  148. return -EFAULT;
  149. err = do_ioctl(file, cmd, (unsigned long)kevent);
  150. if (!err) {
  151. err = convert_in_user(&kevent->type, &up->type);
  152. err |= convert_in_user(&kevent->timestamp, &up->timestamp);
  153. err |= convert_in_user(&kevent->u.size.w, &up->u.size.w);
  154. err |= convert_in_user(&kevent->u.size.h, &up->u.size.h);
  155. err |= convert_in_user(&kevent->u.size.aspect_ratio,
  156. &up->u.size.aspect_ratio);
  157. if (err)
  158. err = -EFAULT;
  159. }
  160. return err;
  161. }
  162. struct compat_video_still_picture {
  163. compat_uptr_t iFrame;
  164. int32_t size;
  165. };
  166. static int do_video_stillpicture(struct file *file,
  167. unsigned int cmd, struct compat_video_still_picture __user *up)
  168. {
  169. struct video_still_picture __user *up_native;
  170. compat_uptr_t fp;
  171. int32_t size;
  172. int err;
  173. err = get_user(fp, &up->iFrame);
  174. err |= get_user(size, &up->size);
  175. if (err)
  176. return -EFAULT;
  177. up_native =
  178. compat_alloc_user_space(sizeof(struct video_still_picture));
  179. err = put_user(compat_ptr(fp), &up_native->iFrame);
  180. err |= put_user(size, &up_native->size);
  181. if (err)
  182. return -EFAULT;
  183. err = do_ioctl(file, cmd, (unsigned long) up_native);
  184. return err;
  185. }
  186. struct compat_video_spu_palette {
  187. int length;
  188. compat_uptr_t palette;
  189. };
  190. static int do_video_set_spu_palette(struct file *file,
  191. unsigned int cmd, struct compat_video_spu_palette __user *up)
  192. {
  193. struct video_spu_palette __user *up_native;
  194. compat_uptr_t palp;
  195. int length, err;
  196. err = get_user(palp, &up->palette);
  197. err |= get_user(length, &up->length);
  198. if (err)
  199. return -EFAULT;
  200. up_native = compat_alloc_user_space(sizeof(struct video_spu_palette));
  201. err = put_user(compat_ptr(palp), &up_native->palette);
  202. err |= put_user(length, &up_native->length);
  203. if (err)
  204. return -EFAULT;
  205. err = do_ioctl(file, cmd, (unsigned long) up_native);
  206. return err;
  207. }
  208. #ifdef CONFIG_BLOCK
  209. typedef struct sg_io_hdr32 {
  210. compat_int_t interface_id; /* [i] 'S' for SCSI generic (required) */
  211. compat_int_t dxfer_direction; /* [i] data transfer direction */
  212. unsigned char cmd_len; /* [i] SCSI command length ( <= 16 bytes) */
  213. unsigned char mx_sb_len; /* [i] max length to write to sbp */
  214. unsigned short iovec_count; /* [i] 0 implies no scatter gather */
  215. compat_uint_t dxfer_len; /* [i] byte count of data transfer */
  216. compat_uint_t dxferp; /* [i], [*io] points to data transfer memory
  217. or scatter gather list */
  218. compat_uptr_t cmdp; /* [i], [*i] points to command to perform */
  219. compat_uptr_t sbp; /* [i], [*o] points to sense_buffer memory */
  220. compat_uint_t timeout; /* [i] MAX_UINT->no timeout (unit: millisec) */
  221. compat_uint_t flags; /* [i] 0 -> default, see SG_FLAG... */
  222. compat_int_t pack_id; /* [i->o] unused internally (normally) */
  223. compat_uptr_t usr_ptr; /* [i->o] unused internally */
  224. unsigned char status; /* [o] scsi status */
  225. unsigned char masked_status; /* [o] shifted, masked scsi status */
  226. unsigned char msg_status; /* [o] messaging level data (optional) */
  227. unsigned char sb_len_wr; /* [o] byte count actually written to sbp */
  228. unsigned short host_status; /* [o] errors from host adapter */
  229. unsigned short driver_status; /* [o] errors from software driver */
  230. compat_int_t resid; /* [o] dxfer_len - actual_transferred */
  231. compat_uint_t duration; /* [o] time taken by cmd (unit: millisec) */
  232. compat_uint_t info; /* [o] auxiliary information */
  233. } sg_io_hdr32_t; /* 64 bytes long (on sparc32) */
  234. typedef struct sg_iovec32 {
  235. compat_uint_t iov_base;
  236. compat_uint_t iov_len;
  237. } sg_iovec32_t;
  238. static int sg_build_iovec(sg_io_hdr_t __user *sgio, void __user *dxferp, u16 iovec_count)
  239. {
  240. sg_iovec_t __user *iov = (sg_iovec_t __user *) (sgio + 1);
  241. sg_iovec32_t __user *iov32 = dxferp;
  242. int i;
  243. for (i = 0; i < iovec_count; i++) {
  244. u32 base, len;
  245. if (get_user(base, &iov32[i].iov_base) ||
  246. get_user(len, &iov32[i].iov_len) ||
  247. put_user(compat_ptr(base), &iov[i].iov_base) ||
  248. put_user(len, &iov[i].iov_len))
  249. return -EFAULT;
  250. }
  251. if (put_user(iov, &sgio->dxferp))
  252. return -EFAULT;
  253. return 0;
  254. }
  255. static int sg_ioctl_trans(struct file *file, unsigned int cmd,
  256. sg_io_hdr32_t __user *sgio32)
  257. {
  258. sg_io_hdr_t __user *sgio;
  259. u16 iovec_count;
  260. u32 data;
  261. void __user *dxferp;
  262. int err;
  263. int interface_id;
  264. if (get_user(interface_id, &sgio32->interface_id))
  265. return -EFAULT;
  266. if (interface_id != 'S')
  267. return do_ioctl(file, cmd, (unsigned long)sgio32);
  268. if (get_user(iovec_count, &sgio32->iovec_count))
  269. return -EFAULT;
  270. {
  271. void __user *top = compat_alloc_user_space(0);
  272. void __user *new = compat_alloc_user_space(sizeof(sg_io_hdr_t) +
  273. (iovec_count * sizeof(sg_iovec_t)));
  274. if (new > top)
  275. return -EINVAL;
  276. sgio = new;
  277. }
  278. /* Ok, now construct. */
  279. if (copy_in_user(&sgio->interface_id, &sgio32->interface_id,
  280. (2 * sizeof(int)) +
  281. (2 * sizeof(unsigned char)) +
  282. (1 * sizeof(unsigned short)) +
  283. (1 * sizeof(unsigned int))))
  284. return -EFAULT;
  285. if (get_user(data, &sgio32->dxferp))
  286. return -EFAULT;
  287. dxferp = compat_ptr(data);
  288. if (iovec_count) {
  289. if (sg_build_iovec(sgio, dxferp, iovec_count))
  290. return -EFAULT;
  291. } else {
  292. if (put_user(dxferp, &sgio->dxferp))
  293. return -EFAULT;
  294. }
  295. {
  296. unsigned char __user *cmdp;
  297. unsigned char __user *sbp;
  298. if (get_user(data, &sgio32->cmdp))
  299. return -EFAULT;
  300. cmdp = compat_ptr(data);
  301. if (get_user(data, &sgio32->sbp))
  302. return -EFAULT;
  303. sbp = compat_ptr(data);
  304. if (put_user(cmdp, &sgio->cmdp) ||
  305. put_user(sbp, &sgio->sbp))
  306. return -EFAULT;
  307. }
  308. if (copy_in_user(&sgio->timeout, &sgio32->timeout,
  309. 3 * sizeof(int)))
  310. return -EFAULT;
  311. if (get_user(data, &sgio32->usr_ptr))
  312. return -EFAULT;
  313. if (put_user(compat_ptr(data), &sgio->usr_ptr))
  314. return -EFAULT;
  315. err = do_ioctl(file, cmd, (unsigned long) sgio);
  316. if (err >= 0) {
  317. void __user *datap;
  318. if (copy_in_user(&sgio32->pack_id, &sgio->pack_id,
  319. sizeof(int)) ||
  320. get_user(datap, &sgio->usr_ptr) ||
  321. put_user((u32)(unsigned long)datap,
  322. &sgio32->usr_ptr) ||
  323. copy_in_user(&sgio32->status, &sgio->status,
  324. (4 * sizeof(unsigned char)) +
  325. (2 * sizeof(unsigned short)) +
  326. (3 * sizeof(int))))
  327. err = -EFAULT;
  328. }
  329. return err;
  330. }
  331. struct compat_sg_req_info { /* used by SG_GET_REQUEST_TABLE ioctl() */
  332. char req_state;
  333. char orphan;
  334. char sg_io_owned;
  335. char problem;
  336. int pack_id;
  337. compat_uptr_t usr_ptr;
  338. unsigned int duration;
  339. int unused;
  340. };
  341. static int sg_grt_trans(struct file *file,
  342. unsigned int cmd, struct compat_sg_req_info __user *o)
  343. {
  344. int err, i;
  345. sg_req_info_t __user *r;
  346. r = compat_alloc_user_space(sizeof(sg_req_info_t)*SG_MAX_QUEUE);
  347. err = do_ioctl(file, cmd, (unsigned long)r);
  348. if (err < 0)
  349. return err;
  350. for (i = 0; i < SG_MAX_QUEUE; i++) {
  351. void __user *ptr;
  352. int d;
  353. if (copy_in_user(o + i, r + i, offsetof(sg_req_info_t, usr_ptr)) ||
  354. get_user(ptr, &r[i].usr_ptr) ||
  355. get_user(d, &r[i].duration) ||
  356. put_user((u32)(unsigned long)(ptr), &o[i].usr_ptr) ||
  357. put_user(d, &o[i].duration))
  358. return -EFAULT;
  359. }
  360. return err;
  361. }
  362. #endif /* CONFIG_BLOCK */
  363. struct sock_fprog32 {
  364. unsigned short len;
  365. compat_caddr_t filter;
  366. };
  367. #define PPPIOCSPASS32 _IOW('t', 71, struct sock_fprog32)
  368. #define PPPIOCSACTIVE32 _IOW('t', 70, struct sock_fprog32)
  369. static int ppp_sock_fprog_ioctl_trans(struct file *file,
  370. unsigned int cmd, struct sock_fprog32 __user *u_fprog32)
  371. {
  372. struct sock_fprog __user *u_fprog64 = compat_alloc_user_space(sizeof(struct sock_fprog));
  373. void __user *fptr64;
  374. u32 fptr32;
  375. u16 flen;
  376. if (get_user(flen, &u_fprog32->len) ||
  377. get_user(fptr32, &u_fprog32->filter))
  378. return -EFAULT;
  379. fptr64 = compat_ptr(fptr32);
  380. if (put_user(flen, &u_fprog64->len) ||
  381. put_user(fptr64, &u_fprog64->filter))
  382. return -EFAULT;
  383. if (cmd == PPPIOCSPASS32)
  384. cmd = PPPIOCSPASS;
  385. else
  386. cmd = PPPIOCSACTIVE;
  387. return do_ioctl(file, cmd, (unsigned long) u_fprog64);
  388. }
  389. struct ppp_option_data32 {
  390. compat_caddr_t ptr;
  391. u32 length;
  392. compat_int_t transmit;
  393. };
  394. #define PPPIOCSCOMPRESS32 _IOW('t', 77, struct ppp_option_data32)
  395. struct ppp_idle32 {
  396. compat_time_t xmit_idle;
  397. compat_time_t recv_idle;
  398. };
  399. #define PPPIOCGIDLE32 _IOR('t', 63, struct ppp_idle32)
  400. static int ppp_gidle(struct file *file, unsigned int cmd,
  401. struct ppp_idle32 __user *idle32)
  402. {
  403. struct ppp_idle __user *idle;
  404. __kernel_time_t xmit, recv;
  405. int err;
  406. idle = compat_alloc_user_space(sizeof(*idle));
  407. err = do_ioctl(file, PPPIOCGIDLE, (unsigned long) idle);
  408. if (!err) {
  409. if (get_user(xmit, &idle->xmit_idle) ||
  410. get_user(recv, &idle->recv_idle) ||
  411. put_user(xmit, &idle32->xmit_idle) ||
  412. put_user(recv, &idle32->recv_idle))
  413. err = -EFAULT;
  414. }
  415. return err;
  416. }
  417. static int ppp_scompress(struct file *file, unsigned int cmd,
  418. struct ppp_option_data32 __user *odata32)
  419. {
  420. struct ppp_option_data __user *odata;
  421. __u32 data;
  422. void __user *datap;
  423. odata = compat_alloc_user_space(sizeof(*odata));
  424. if (get_user(data, &odata32->ptr))
  425. return -EFAULT;
  426. datap = compat_ptr(data);
  427. if (put_user(datap, &odata->ptr))
  428. return -EFAULT;
  429. if (copy_in_user(&odata->length, &odata32->length,
  430. sizeof(__u32) + sizeof(int)))
  431. return -EFAULT;
  432. return do_ioctl(file, PPPIOCSCOMPRESS, (unsigned long) odata);
  433. }
  434. #ifdef CONFIG_BLOCK
  435. struct mtget32 {
  436. compat_long_t mt_type;
  437. compat_long_t mt_resid;
  438. compat_long_t mt_dsreg;
  439. compat_long_t mt_gstat;
  440. compat_long_t mt_erreg;
  441. compat_daddr_t mt_fileno;
  442. compat_daddr_t mt_blkno;
  443. };
  444. #define MTIOCGET32 _IOR('m', 2, struct mtget32)
  445. struct mtpos32 {
  446. compat_long_t mt_blkno;
  447. };
  448. #define MTIOCPOS32 _IOR('m', 3, struct mtpos32)
  449. static int mt_ioctl_trans(struct file *file,
  450. unsigned int cmd, void __user *argp)
  451. {
  452. /* NULL initialization to make gcc shut up */
  453. struct mtget __user *get = NULL;
  454. struct mtget32 __user *umget32;
  455. struct mtpos __user *pos = NULL;
  456. struct mtpos32 __user *upos32;
  457. unsigned long kcmd;
  458. void *karg;
  459. int err = 0;
  460. switch(cmd) {
  461. case MTIOCPOS32:
  462. kcmd = MTIOCPOS;
  463. pos = compat_alloc_user_space(sizeof(*pos));
  464. karg = pos;
  465. break;
  466. default: /* MTIOCGET32 */
  467. kcmd = MTIOCGET;
  468. get = compat_alloc_user_space(sizeof(*get));
  469. karg = get;
  470. break;
  471. }
  472. if (karg == NULL)
  473. return -EFAULT;
  474. err = do_ioctl(file, kcmd, (unsigned long)karg);
  475. if (err)
  476. return err;
  477. switch (cmd) {
  478. case MTIOCPOS32:
  479. upos32 = argp;
  480. err = convert_in_user(&pos->mt_blkno, &upos32->mt_blkno);
  481. break;
  482. case MTIOCGET32:
  483. umget32 = argp;
  484. err = convert_in_user(&get->mt_type, &umget32->mt_type);
  485. err |= convert_in_user(&get->mt_resid, &umget32->mt_resid);
  486. err |= convert_in_user(&get->mt_dsreg, &umget32->mt_dsreg);
  487. err |= convert_in_user(&get->mt_gstat, &umget32->mt_gstat);
  488. err |= convert_in_user(&get->mt_erreg, &umget32->mt_erreg);
  489. err |= convert_in_user(&get->mt_fileno, &umget32->mt_fileno);
  490. err |= convert_in_user(&get->mt_blkno, &umget32->mt_blkno);
  491. break;
  492. }
  493. return err ? -EFAULT: 0;
  494. }
  495. #endif /* CONFIG_BLOCK */
  496. /* Bluetooth ioctls */
  497. #define HCIUARTSETPROTO _IOW('U', 200, int)
  498. #define HCIUARTGETPROTO _IOR('U', 201, int)
  499. #define HCIUARTGETDEVICE _IOR('U', 202, int)
  500. #define HCIUARTSETFLAGS _IOW('U', 203, int)
  501. #define HCIUARTGETFLAGS _IOR('U', 204, int)
  502. #define BNEPCONNADD _IOW('B', 200, int)
  503. #define BNEPCONNDEL _IOW('B', 201, int)
  504. #define BNEPGETCONNLIST _IOR('B', 210, int)
  505. #define BNEPGETCONNINFO _IOR('B', 211, int)
  506. #define BNEPGETSUPPFEAT _IOR('B', 212, int)
  507. #define CMTPCONNADD _IOW('C', 200, int)
  508. #define CMTPCONNDEL _IOW('C', 201, int)
  509. #define CMTPGETCONNLIST _IOR('C', 210, int)
  510. #define CMTPGETCONNINFO _IOR('C', 211, int)
  511. #define HIDPCONNADD _IOW('H', 200, int)
  512. #define HIDPCONNDEL _IOW('H', 201, int)
  513. #define HIDPGETCONNLIST _IOR('H', 210, int)
  514. #define HIDPGETCONNINFO _IOR('H', 211, int)
  515. struct serial_struct32 {
  516. compat_int_t type;
  517. compat_int_t line;
  518. compat_uint_t port;
  519. compat_int_t irq;
  520. compat_int_t flags;
  521. compat_int_t xmit_fifo_size;
  522. compat_int_t custom_divisor;
  523. compat_int_t baud_base;
  524. unsigned short close_delay;
  525. char io_type;
  526. char reserved_char[1];
  527. compat_int_t hub6;
  528. unsigned short closing_wait; /* time to wait before closing */
  529. unsigned short closing_wait2; /* no longer used... */
  530. compat_uint_t iomem_base;
  531. unsigned short iomem_reg_shift;
  532. unsigned int port_high;
  533. /* compat_ulong_t iomap_base FIXME */
  534. compat_int_t reserved[1];
  535. };
  536. static int serial_struct_ioctl(struct file *file,
  537. unsigned cmd, struct serial_struct32 __user *ss32)
  538. {
  539. typedef struct serial_struct32 SS32;
  540. int err;
  541. struct serial_struct __user *ss = compat_alloc_user_space(sizeof(*ss));
  542. __u32 udata;
  543. unsigned int base;
  544. unsigned char *iomem_base;
  545. if (ss == NULL)
  546. return -EFAULT;
  547. if (cmd == TIOCSSERIAL) {
  548. if (copy_in_user(ss, ss32, offsetof(SS32, iomem_base)) ||
  549. get_user(udata, &ss32->iomem_base))
  550. return -EFAULT;
  551. iomem_base = compat_ptr(udata);
  552. if (put_user(iomem_base, &ss->iomem_base) ||
  553. convert_in_user(&ss32->iomem_reg_shift,
  554. &ss->iomem_reg_shift) ||
  555. convert_in_user(&ss32->port_high, &ss->port_high) ||
  556. put_user(0UL, &ss->iomap_base))
  557. return -EFAULT;
  558. }
  559. err = do_ioctl(file, cmd, (unsigned long)ss);
  560. if (cmd == TIOCGSERIAL && err >= 0) {
  561. if (copy_in_user(ss32, ss, offsetof(SS32, iomem_base)) ||
  562. get_user(iomem_base, &ss->iomem_base))
  563. return -EFAULT;
  564. base = (unsigned long)iomem_base >> 32 ?
  565. 0xffffffff : (unsigned)(unsigned long)iomem_base;
  566. if (put_user(base, &ss32->iomem_base) ||
  567. convert_in_user(&ss->iomem_reg_shift,
  568. &ss32->iomem_reg_shift) ||
  569. convert_in_user(&ss->port_high, &ss32->port_high))
  570. return -EFAULT;
  571. }
  572. return err;
  573. }
  574. /*
  575. * I2C layer ioctls
  576. */
  577. struct i2c_msg32 {
  578. u16 addr;
  579. u16 flags;
  580. u16 len;
  581. compat_caddr_t buf;
  582. };
  583. struct i2c_rdwr_ioctl_data32 {
  584. compat_caddr_t msgs; /* struct i2c_msg __user *msgs */
  585. u32 nmsgs;
  586. };
  587. struct i2c_smbus_ioctl_data32 {
  588. u8 read_write;
  589. u8 command;
  590. u32 size;
  591. compat_caddr_t data; /* union i2c_smbus_data *data */
  592. };
  593. struct i2c_rdwr_aligned {
  594. struct i2c_rdwr_ioctl_data cmd;
  595. struct i2c_msg msgs[0];
  596. };
  597. static int do_i2c_rdwr_ioctl(struct file *file,
  598. unsigned int cmd, struct i2c_rdwr_ioctl_data32 __user *udata)
  599. {
  600. struct i2c_rdwr_aligned __user *tdata;
  601. struct i2c_msg __user *tmsgs;
  602. struct i2c_msg32 __user *umsgs;
  603. compat_caddr_t datap;
  604. u32 nmsgs;
  605. int i;
  606. if (get_user(nmsgs, &udata->nmsgs))
  607. return -EFAULT;
  608. if (nmsgs > I2C_RDWR_IOCTL_MAX_MSGS)
  609. return -EINVAL;
  610. if (get_user(datap, &udata->msgs))
  611. return -EFAULT;
  612. umsgs = compat_ptr(datap);
  613. tdata = compat_alloc_user_space(sizeof(*tdata) +
  614. nmsgs * sizeof(struct i2c_msg));
  615. tmsgs = &tdata->msgs[0];
  616. if (put_user(nmsgs, &tdata->cmd.nmsgs) ||
  617. put_user(tmsgs, &tdata->cmd.msgs))
  618. return -EFAULT;
  619. for (i = 0; i < nmsgs; i++) {
  620. if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
  621. return -EFAULT;
  622. if (get_user(datap, &umsgs[i].buf) ||
  623. put_user(compat_ptr(datap), &tmsgs[i].buf))
  624. return -EFAULT;
  625. }
  626. return do_ioctl(file, cmd, (unsigned long)tdata);
  627. }
  628. static int do_i2c_smbus_ioctl(struct file *file,
  629. unsigned int cmd, struct i2c_smbus_ioctl_data32 __user *udata)
  630. {
  631. struct i2c_smbus_ioctl_data __user *tdata;
  632. compat_caddr_t datap;
  633. tdata = compat_alloc_user_space(sizeof(*tdata));
  634. if (tdata == NULL)
  635. return -ENOMEM;
  636. if (!access_ok(VERIFY_WRITE, tdata, sizeof(*tdata)))
  637. return -EFAULT;
  638. if (!access_ok(VERIFY_READ, udata, sizeof(*udata)))
  639. return -EFAULT;
  640. if (__copy_in_user(&tdata->read_write, &udata->read_write, 2 * sizeof(u8)))
  641. return -EFAULT;
  642. if (__copy_in_user(&tdata->size, &udata->size, 2 * sizeof(u32)))
  643. return -EFAULT;
  644. if (__get_user(datap, &udata->data) ||
  645. __put_user(compat_ptr(datap), &tdata->data))
  646. return -EFAULT;
  647. return do_ioctl(file, cmd, (unsigned long)tdata);
  648. }
  649. #define RTC_IRQP_READ32 _IOR('p', 0x0b, compat_ulong_t)
  650. #define RTC_IRQP_SET32 _IOW('p', 0x0c, compat_ulong_t)
  651. #define RTC_EPOCH_READ32 _IOR('p', 0x0d, compat_ulong_t)
  652. #define RTC_EPOCH_SET32 _IOW('p', 0x0e, compat_ulong_t)
  653. static int rtc_ioctl(struct file *file,
  654. unsigned cmd, void __user *argp)
  655. {
  656. unsigned long __user *valp = compat_alloc_user_space(sizeof(*valp));
  657. int ret;
  658. if (valp == NULL)
  659. return -EFAULT;
  660. switch (cmd) {
  661. case RTC_IRQP_READ32:
  662. case RTC_EPOCH_READ32:
  663. ret = do_ioctl(file, (cmd == RTC_IRQP_READ32) ?
  664. RTC_IRQP_READ : RTC_EPOCH_READ,
  665. (unsigned long)valp);
  666. if (ret)
  667. return ret;
  668. return convert_in_user(valp, (unsigned int __user *)argp);
  669. case RTC_IRQP_SET32:
  670. return do_ioctl(file, RTC_IRQP_SET, (unsigned long)argp);
  671. case RTC_EPOCH_SET32:
  672. return do_ioctl(file, RTC_EPOCH_SET, (unsigned long)argp);
  673. }
  674. return -ENOIOCTLCMD;
  675. }
  676. /* on ia32 l_start is on a 32-bit boundary */
  677. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  678. struct space_resv_32 {
  679. __s16 l_type;
  680. __s16 l_whence;
  681. __s64 l_start __attribute__((packed));
  682. /* len == 0 means until end of file */
  683. __s64 l_len __attribute__((packed));
  684. __s32 l_sysid;
  685. __u32 l_pid;
  686. __s32 l_pad[4]; /* reserve area */
  687. };
  688. #define FS_IOC_RESVSP_32 _IOW ('X', 40, struct space_resv_32)
  689. #define FS_IOC_RESVSP64_32 _IOW ('X', 42, struct space_resv_32)
  690. /* just account for different alignment */
  691. static int compat_ioctl_preallocate(struct file *file,
  692. struct space_resv_32 __user *p32)
  693. {
  694. struct space_resv __user *p = compat_alloc_user_space(sizeof(*p));
  695. if (copy_in_user(&p->l_type, &p32->l_type, sizeof(s16)) ||
  696. copy_in_user(&p->l_whence, &p32->l_whence, sizeof(s16)) ||
  697. copy_in_user(&p->l_start, &p32->l_start, sizeof(s64)) ||
  698. copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
  699. copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
  700. copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
  701. copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
  702. return -EFAULT;
  703. return ioctl_preallocate(file, p);
  704. }
  705. #endif
  706. /*
  707. * simple reversible transform to make our table more evenly
  708. * distributed after sorting.
  709. */
  710. #define XFORM(i) (((i) ^ ((i) << 27) ^ ((i) << 17)) & 0xffffffff)
  711. #define COMPATIBLE_IOCTL(cmd) XFORM(cmd),
  712. /* ioctl should not be warned about even if it's not implemented.
  713. Valid reasons to use this:
  714. - It is implemented with ->compat_ioctl on some device, but programs
  715. call it on others too.
  716. - The ioctl is not implemented in the native kernel, but programs
  717. call it commonly anyways.
  718. Most other reasons are not valid. */
  719. #define IGNORE_IOCTL(cmd) COMPATIBLE_IOCTL(cmd)
  720. static unsigned int ioctl_pointer[] = {
  721. /* compatible ioctls first */
  722. COMPATIBLE_IOCTL(0x4B50) /* KDGHWCLK - not in the kernel, but don't complain */
  723. COMPATIBLE_IOCTL(0x4B51) /* KDSHWCLK - not in the kernel, but don't complain */
  724. /* Big T */
  725. COMPATIBLE_IOCTL(TCGETA)
  726. COMPATIBLE_IOCTL(TCSETA)
  727. COMPATIBLE_IOCTL(TCSETAW)
  728. COMPATIBLE_IOCTL(TCSETAF)
  729. COMPATIBLE_IOCTL(TCSBRK)
  730. COMPATIBLE_IOCTL(TCXONC)
  731. COMPATIBLE_IOCTL(TCFLSH)
  732. COMPATIBLE_IOCTL(TCGETS)
  733. COMPATIBLE_IOCTL(TCSETS)
  734. COMPATIBLE_IOCTL(TCSETSW)
  735. COMPATIBLE_IOCTL(TCSETSF)
  736. COMPATIBLE_IOCTL(TIOCLINUX)
  737. COMPATIBLE_IOCTL(TIOCSBRK)
  738. COMPATIBLE_IOCTL(TIOCGDEV)
  739. COMPATIBLE_IOCTL(TIOCCBRK)
  740. COMPATIBLE_IOCTL(TIOCGSID)
  741. COMPATIBLE_IOCTL(TIOCGICOUNT)
  742. COMPATIBLE_IOCTL(TIOCGPKT)
  743. COMPATIBLE_IOCTL(TIOCGPTLCK)
  744. COMPATIBLE_IOCTL(TIOCGEXCL)
  745. /* Little t */
  746. COMPATIBLE_IOCTL(TIOCGETD)
  747. COMPATIBLE_IOCTL(TIOCSETD)
  748. COMPATIBLE_IOCTL(TIOCEXCL)
  749. COMPATIBLE_IOCTL(TIOCNXCL)
  750. COMPATIBLE_IOCTL(TIOCCONS)
  751. COMPATIBLE_IOCTL(TIOCGSOFTCAR)
  752. COMPATIBLE_IOCTL(TIOCSSOFTCAR)
  753. COMPATIBLE_IOCTL(TIOCSWINSZ)
  754. COMPATIBLE_IOCTL(TIOCGWINSZ)
  755. COMPATIBLE_IOCTL(TIOCMGET)
  756. COMPATIBLE_IOCTL(TIOCMBIC)
  757. COMPATIBLE_IOCTL(TIOCMBIS)
  758. COMPATIBLE_IOCTL(TIOCMSET)
  759. COMPATIBLE_IOCTL(TIOCPKT)
  760. COMPATIBLE_IOCTL(TIOCNOTTY)
  761. COMPATIBLE_IOCTL(TIOCSTI)
  762. COMPATIBLE_IOCTL(TIOCOUTQ)
  763. COMPATIBLE_IOCTL(TIOCSPGRP)
  764. COMPATIBLE_IOCTL(TIOCGPGRP)
  765. COMPATIBLE_IOCTL(TIOCGPTN)
  766. COMPATIBLE_IOCTL(TIOCSPTLCK)
  767. COMPATIBLE_IOCTL(TIOCSERGETLSR)
  768. COMPATIBLE_IOCTL(TIOCSIG)
  769. #ifdef TIOCSRS485
  770. COMPATIBLE_IOCTL(TIOCSRS485)
  771. #endif
  772. #ifdef TIOCGRS485
  773. COMPATIBLE_IOCTL(TIOCGRS485)
  774. #endif
  775. #ifdef TCGETS2
  776. COMPATIBLE_IOCTL(TCGETS2)
  777. COMPATIBLE_IOCTL(TCSETS2)
  778. COMPATIBLE_IOCTL(TCSETSW2)
  779. COMPATIBLE_IOCTL(TCSETSF2)
  780. #endif
  781. /* Little f */
  782. COMPATIBLE_IOCTL(FIOCLEX)
  783. COMPATIBLE_IOCTL(FIONCLEX)
  784. COMPATIBLE_IOCTL(FIOASYNC)
  785. COMPATIBLE_IOCTL(FIONBIO)
  786. COMPATIBLE_IOCTL(FIONREAD) /* This is also TIOCINQ */
  787. COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
  788. /* 0x00 */
  789. COMPATIBLE_IOCTL(FIBMAP)
  790. COMPATIBLE_IOCTL(FIGETBSZ)
  791. /* 'X' - originally XFS but some now in the VFS */
  792. COMPATIBLE_IOCTL(FIFREEZE)
  793. COMPATIBLE_IOCTL(FITHAW)
  794. COMPATIBLE_IOCTL(FITRIM)
  795. COMPATIBLE_IOCTL(KDGETKEYCODE)
  796. COMPATIBLE_IOCTL(KDSETKEYCODE)
  797. COMPATIBLE_IOCTL(KDGKBTYPE)
  798. COMPATIBLE_IOCTL(KDGETMODE)
  799. COMPATIBLE_IOCTL(KDGKBMODE)
  800. COMPATIBLE_IOCTL(KDGKBMETA)
  801. COMPATIBLE_IOCTL(KDGKBENT)
  802. COMPATIBLE_IOCTL(KDSKBENT)
  803. COMPATIBLE_IOCTL(KDGKBSENT)
  804. COMPATIBLE_IOCTL(KDSKBSENT)
  805. COMPATIBLE_IOCTL(KDGKBDIACR)
  806. COMPATIBLE_IOCTL(KDSKBDIACR)
  807. COMPATIBLE_IOCTL(KDGKBDIACRUC)
  808. COMPATIBLE_IOCTL(KDSKBDIACRUC)
  809. COMPATIBLE_IOCTL(KDKBDREP)
  810. COMPATIBLE_IOCTL(KDGKBLED)
  811. COMPATIBLE_IOCTL(KDGETLED)
  812. #ifdef CONFIG_BLOCK
  813. /* Big S */
  814. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_IDLUN)
  815. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORLOCK)
  816. COMPATIBLE_IOCTL(SCSI_IOCTL_DOORUNLOCK)
  817. COMPATIBLE_IOCTL(SCSI_IOCTL_TEST_UNIT_READY)
  818. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_BUS_NUMBER)
  819. COMPATIBLE_IOCTL(SCSI_IOCTL_SEND_COMMAND)
  820. COMPATIBLE_IOCTL(SCSI_IOCTL_PROBE_HOST)
  821. COMPATIBLE_IOCTL(SCSI_IOCTL_GET_PCI)
  822. #endif
  823. /* Big V (don't complain on serial console) */
  824. IGNORE_IOCTL(VT_OPENQRY)
  825. IGNORE_IOCTL(VT_GETMODE)
  826. /* Little p (/dev/rtc, /dev/envctrl, etc.) */
  827. COMPATIBLE_IOCTL(RTC_AIE_ON)
  828. COMPATIBLE_IOCTL(RTC_AIE_OFF)
  829. COMPATIBLE_IOCTL(RTC_UIE_ON)
  830. COMPATIBLE_IOCTL(RTC_UIE_OFF)
  831. COMPATIBLE_IOCTL(RTC_PIE_ON)
  832. COMPATIBLE_IOCTL(RTC_PIE_OFF)
  833. COMPATIBLE_IOCTL(RTC_WIE_ON)
  834. COMPATIBLE_IOCTL(RTC_WIE_OFF)
  835. COMPATIBLE_IOCTL(RTC_ALM_SET)
  836. COMPATIBLE_IOCTL(RTC_ALM_READ)
  837. COMPATIBLE_IOCTL(RTC_RD_TIME)
  838. COMPATIBLE_IOCTL(RTC_SET_TIME)
  839. COMPATIBLE_IOCTL(RTC_WKALM_SET)
  840. COMPATIBLE_IOCTL(RTC_WKALM_RD)
  841. /*
  842. * These two are only for the sbus rtc driver, but
  843. * hwclock tries them on every rtc device first when
  844. * running on sparc. On other architectures the entries
  845. * are useless but harmless.
  846. */
  847. COMPATIBLE_IOCTL(_IOR('p', 20, int[7])) /* RTCGET */
  848. COMPATIBLE_IOCTL(_IOW('p', 21, int[7])) /* RTCSET */
  849. /* Little m */
  850. COMPATIBLE_IOCTL(MTIOCTOP)
  851. /* Socket level stuff */
  852. COMPATIBLE_IOCTL(FIOQSIZE)
  853. #ifdef CONFIG_BLOCK
  854. /* md calls this on random blockdevs */
  855. IGNORE_IOCTL(RAID_VERSION)
  856. /* qemu/qemu-img might call these two on plain files for probing */
  857. IGNORE_IOCTL(CDROM_DRIVE_STATUS)
  858. IGNORE_IOCTL(FDGETPRM32)
  859. /* SG stuff */
  860. COMPATIBLE_IOCTL(SG_SET_TIMEOUT)
  861. COMPATIBLE_IOCTL(SG_GET_TIMEOUT)
  862. COMPATIBLE_IOCTL(SG_EMULATED_HOST)
  863. COMPATIBLE_IOCTL(SG_GET_TRANSFORM)
  864. COMPATIBLE_IOCTL(SG_SET_RESERVED_SIZE)
  865. COMPATIBLE_IOCTL(SG_GET_RESERVED_SIZE)
  866. COMPATIBLE_IOCTL(SG_GET_SCSI_ID)
  867. COMPATIBLE_IOCTL(SG_SET_FORCE_LOW_DMA)
  868. COMPATIBLE_IOCTL(SG_GET_LOW_DMA)
  869. COMPATIBLE_IOCTL(SG_SET_FORCE_PACK_ID)
  870. COMPATIBLE_IOCTL(SG_GET_PACK_ID)
  871. COMPATIBLE_IOCTL(SG_GET_NUM_WAITING)
  872. COMPATIBLE_IOCTL(SG_SET_DEBUG)
  873. COMPATIBLE_IOCTL(SG_GET_SG_TABLESIZE)
  874. COMPATIBLE_IOCTL(SG_GET_COMMAND_Q)
  875. COMPATIBLE_IOCTL(SG_SET_COMMAND_Q)
  876. COMPATIBLE_IOCTL(SG_GET_VERSION_NUM)
  877. COMPATIBLE_IOCTL(SG_NEXT_CMD_LEN)
  878. COMPATIBLE_IOCTL(SG_SCSI_RESET)
  879. COMPATIBLE_IOCTL(SG_GET_REQUEST_TABLE)
  880. COMPATIBLE_IOCTL(SG_SET_KEEP_ORPHAN)
  881. COMPATIBLE_IOCTL(SG_GET_KEEP_ORPHAN)
  882. #endif
  883. /* PPP stuff */
  884. COMPATIBLE_IOCTL(PPPIOCGFLAGS)
  885. COMPATIBLE_IOCTL(PPPIOCSFLAGS)
  886. COMPATIBLE_IOCTL(PPPIOCGASYNCMAP)
  887. COMPATIBLE_IOCTL(PPPIOCSASYNCMAP)
  888. COMPATIBLE_IOCTL(PPPIOCGUNIT)
  889. COMPATIBLE_IOCTL(PPPIOCGRASYNCMAP)
  890. COMPATIBLE_IOCTL(PPPIOCSRASYNCMAP)
  891. COMPATIBLE_IOCTL(PPPIOCGMRU)
  892. COMPATIBLE_IOCTL(PPPIOCSMRU)
  893. COMPATIBLE_IOCTL(PPPIOCSMAXCID)
  894. COMPATIBLE_IOCTL(PPPIOCGXASYNCMAP)
  895. COMPATIBLE_IOCTL(PPPIOCSXASYNCMAP)
  896. COMPATIBLE_IOCTL(PPPIOCXFERUNIT)
  897. /* PPPIOCSCOMPRESS is translated */
  898. COMPATIBLE_IOCTL(PPPIOCGNPMODE)
  899. COMPATIBLE_IOCTL(PPPIOCSNPMODE)
  900. COMPATIBLE_IOCTL(PPPIOCGDEBUG)
  901. COMPATIBLE_IOCTL(PPPIOCSDEBUG)
  902. /* PPPIOCSPASS is translated */
  903. /* PPPIOCSACTIVE is translated */
  904. /* PPPIOCGIDLE is translated */
  905. COMPATIBLE_IOCTL(PPPIOCNEWUNIT)
  906. COMPATIBLE_IOCTL(PPPIOCATTACH)
  907. COMPATIBLE_IOCTL(PPPIOCDETACH)
  908. COMPATIBLE_IOCTL(PPPIOCSMRRU)
  909. COMPATIBLE_IOCTL(PPPIOCCONNECT)
  910. COMPATIBLE_IOCTL(PPPIOCDISCONN)
  911. COMPATIBLE_IOCTL(PPPIOCATTCHAN)
  912. COMPATIBLE_IOCTL(PPPIOCGCHAN)
  913. COMPATIBLE_IOCTL(PPPIOCGL2TPSTATS)
  914. /* PPPOX */
  915. COMPATIBLE_IOCTL(PPPOEIOCSFWD)
  916. COMPATIBLE_IOCTL(PPPOEIOCDFWD)
  917. /* ppdev */
  918. COMPATIBLE_IOCTL(PPSETMODE)
  919. COMPATIBLE_IOCTL(PPRSTATUS)
  920. COMPATIBLE_IOCTL(PPRCONTROL)
  921. COMPATIBLE_IOCTL(PPWCONTROL)
  922. COMPATIBLE_IOCTL(PPFCONTROL)
  923. COMPATIBLE_IOCTL(PPRDATA)
  924. COMPATIBLE_IOCTL(PPWDATA)
  925. COMPATIBLE_IOCTL(PPCLAIM)
  926. COMPATIBLE_IOCTL(PPRELEASE)
  927. COMPATIBLE_IOCTL(PPYIELD)
  928. COMPATIBLE_IOCTL(PPEXCL)
  929. COMPATIBLE_IOCTL(PPDATADIR)
  930. COMPATIBLE_IOCTL(PPNEGOT)
  931. COMPATIBLE_IOCTL(PPWCTLONIRQ)
  932. COMPATIBLE_IOCTL(PPCLRIRQ)
  933. COMPATIBLE_IOCTL(PPSETPHASE)
  934. COMPATIBLE_IOCTL(PPGETMODES)
  935. COMPATIBLE_IOCTL(PPGETMODE)
  936. COMPATIBLE_IOCTL(PPGETPHASE)
  937. COMPATIBLE_IOCTL(PPGETFLAGS)
  938. COMPATIBLE_IOCTL(PPSETFLAGS)
  939. /* Big A */
  940. /* sparc only */
  941. /* Big Q for sound/OSS */
  942. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESET)
  943. COMPATIBLE_IOCTL(SNDCTL_SEQ_SYNC)
  944. COMPATIBLE_IOCTL(SNDCTL_SYNTH_INFO)
  945. COMPATIBLE_IOCTL(SNDCTL_SEQ_CTRLRATE)
  946. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETOUTCOUNT)
  947. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETINCOUNT)
  948. COMPATIBLE_IOCTL(SNDCTL_SEQ_PERCMODE)
  949. COMPATIBLE_IOCTL(SNDCTL_FM_LOAD_INSTR)
  950. COMPATIBLE_IOCTL(SNDCTL_SEQ_TESTMIDI)
  951. COMPATIBLE_IOCTL(SNDCTL_SEQ_RESETSAMPLES)
  952. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRSYNTHS)
  953. COMPATIBLE_IOCTL(SNDCTL_SEQ_NRMIDIS)
  954. COMPATIBLE_IOCTL(SNDCTL_MIDI_INFO)
  955. COMPATIBLE_IOCTL(SNDCTL_SEQ_THRESHOLD)
  956. COMPATIBLE_IOCTL(SNDCTL_SYNTH_MEMAVL)
  957. COMPATIBLE_IOCTL(SNDCTL_FM_4OP_ENABLE)
  958. COMPATIBLE_IOCTL(SNDCTL_SEQ_PANIC)
  959. COMPATIBLE_IOCTL(SNDCTL_SEQ_OUTOFBAND)
  960. COMPATIBLE_IOCTL(SNDCTL_SEQ_GETTIME)
  961. COMPATIBLE_IOCTL(SNDCTL_SYNTH_ID)
  962. COMPATIBLE_IOCTL(SNDCTL_SYNTH_CONTROL)
  963. COMPATIBLE_IOCTL(SNDCTL_SYNTH_REMOVESAMPLE)
  964. /* Big T for sound/OSS */
  965. COMPATIBLE_IOCTL(SNDCTL_TMR_TIMEBASE)
  966. COMPATIBLE_IOCTL(SNDCTL_TMR_START)
  967. COMPATIBLE_IOCTL(SNDCTL_TMR_STOP)
  968. COMPATIBLE_IOCTL(SNDCTL_TMR_CONTINUE)
  969. COMPATIBLE_IOCTL(SNDCTL_TMR_TEMPO)
  970. COMPATIBLE_IOCTL(SNDCTL_TMR_SOURCE)
  971. COMPATIBLE_IOCTL(SNDCTL_TMR_METRONOME)
  972. COMPATIBLE_IOCTL(SNDCTL_TMR_SELECT)
  973. /* Little m for sound/OSS */
  974. COMPATIBLE_IOCTL(SNDCTL_MIDI_PRETIME)
  975. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUMODE)
  976. COMPATIBLE_IOCTL(SNDCTL_MIDI_MPUCMD)
  977. /* Big P for sound/OSS */
  978. COMPATIBLE_IOCTL(SNDCTL_DSP_RESET)
  979. COMPATIBLE_IOCTL(SNDCTL_DSP_SYNC)
  980. COMPATIBLE_IOCTL(SNDCTL_DSP_SPEED)
  981. COMPATIBLE_IOCTL(SNDCTL_DSP_STEREO)
  982. COMPATIBLE_IOCTL(SNDCTL_DSP_GETBLKSIZE)
  983. COMPATIBLE_IOCTL(SNDCTL_DSP_CHANNELS)
  984. COMPATIBLE_IOCTL(SOUND_PCM_WRITE_FILTER)
  985. COMPATIBLE_IOCTL(SNDCTL_DSP_POST)
  986. COMPATIBLE_IOCTL(SNDCTL_DSP_SUBDIVIDE)
  987. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFRAGMENT)
  988. COMPATIBLE_IOCTL(SNDCTL_DSP_GETFMTS)
  989. COMPATIBLE_IOCTL(SNDCTL_DSP_SETFMT)
  990. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOSPACE)
  991. COMPATIBLE_IOCTL(SNDCTL_DSP_GETISPACE)
  992. COMPATIBLE_IOCTL(SNDCTL_DSP_NONBLOCK)
  993. COMPATIBLE_IOCTL(SNDCTL_DSP_GETCAPS)
  994. COMPATIBLE_IOCTL(SNDCTL_DSP_GETTRIGGER)
  995. COMPATIBLE_IOCTL(SNDCTL_DSP_SETTRIGGER)
  996. COMPATIBLE_IOCTL(SNDCTL_DSP_GETIPTR)
  997. COMPATIBLE_IOCTL(SNDCTL_DSP_GETOPTR)
  998. /* SNDCTL_DSP_MAPINBUF, XXX needs translation */
  999. /* SNDCTL_DSP_MAPOUTBUF, XXX needs translation */
  1000. COMPATIBLE_IOCTL(SNDCTL_DSP_SETSYNCRO)
  1001. COMPATIBLE_IOCTL(SNDCTL_DSP_SETDUPLEX)
  1002. COMPATIBLE_IOCTL(SNDCTL_DSP_GETODELAY)
  1003. COMPATIBLE_IOCTL(SNDCTL_DSP_PROFILE)
  1004. COMPATIBLE_IOCTL(SOUND_PCM_READ_RATE)
  1005. COMPATIBLE_IOCTL(SOUND_PCM_READ_CHANNELS)
  1006. COMPATIBLE_IOCTL(SOUND_PCM_READ_BITS)
  1007. COMPATIBLE_IOCTL(SOUND_PCM_READ_FILTER)
  1008. /* Big C for sound/OSS */
  1009. COMPATIBLE_IOCTL(SNDCTL_COPR_RESET)
  1010. COMPATIBLE_IOCTL(SNDCTL_COPR_LOAD)
  1011. COMPATIBLE_IOCTL(SNDCTL_COPR_RDATA)
  1012. COMPATIBLE_IOCTL(SNDCTL_COPR_RCODE)
  1013. COMPATIBLE_IOCTL(SNDCTL_COPR_WDATA)
  1014. COMPATIBLE_IOCTL(SNDCTL_COPR_WCODE)
  1015. COMPATIBLE_IOCTL(SNDCTL_COPR_RUN)
  1016. COMPATIBLE_IOCTL(SNDCTL_COPR_HALT)
  1017. COMPATIBLE_IOCTL(SNDCTL_COPR_SENDMSG)
  1018. COMPATIBLE_IOCTL(SNDCTL_COPR_RCVMSG)
  1019. /* Big M for sound/OSS */
  1020. COMPATIBLE_IOCTL(SOUND_MIXER_READ_VOLUME)
  1021. COMPATIBLE_IOCTL(SOUND_MIXER_READ_BASS)
  1022. COMPATIBLE_IOCTL(SOUND_MIXER_READ_TREBLE)
  1023. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SYNTH)
  1024. COMPATIBLE_IOCTL(SOUND_MIXER_READ_PCM)
  1025. COMPATIBLE_IOCTL(SOUND_MIXER_READ_SPEAKER)
  1026. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE)
  1027. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MIC)
  1028. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CD)
  1029. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IMIX)
  1030. COMPATIBLE_IOCTL(SOUND_MIXER_READ_ALTPCM)
  1031. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECLEV)
  1032. COMPATIBLE_IOCTL(SOUND_MIXER_READ_IGAIN)
  1033. COMPATIBLE_IOCTL(SOUND_MIXER_READ_OGAIN)
  1034. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE1)
  1035. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE2)
  1036. COMPATIBLE_IOCTL(SOUND_MIXER_READ_LINE3)
  1037. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL1))
  1038. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL2))
  1039. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_DIGITAL3))
  1040. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEIN))
  1041. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_PHONEOUT))
  1042. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_VIDEO))
  1043. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_RADIO))
  1044. COMPATIBLE_IOCTL(MIXER_READ(SOUND_MIXER_MONITOR))
  1045. COMPATIBLE_IOCTL(SOUND_MIXER_READ_MUTE)
  1046. /* SOUND_MIXER_READ_ENHANCE, same value as READ_MUTE */
  1047. /* SOUND_MIXER_READ_LOUD, same value as READ_MUTE */
  1048. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECSRC)
  1049. COMPATIBLE_IOCTL(SOUND_MIXER_READ_DEVMASK)
  1050. COMPATIBLE_IOCTL(SOUND_MIXER_READ_RECMASK)
  1051. COMPATIBLE_IOCTL(SOUND_MIXER_READ_STEREODEVS)
  1052. COMPATIBLE_IOCTL(SOUND_MIXER_READ_CAPS)
  1053. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_VOLUME)
  1054. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_BASS)
  1055. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_TREBLE)
  1056. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SYNTH)
  1057. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_PCM)
  1058. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_SPEAKER)
  1059. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE)
  1060. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MIC)
  1061. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_CD)
  1062. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IMIX)
  1063. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_ALTPCM)
  1064. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECLEV)
  1065. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_IGAIN)
  1066. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_OGAIN)
  1067. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE1)
  1068. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE2)
  1069. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_LINE3)
  1070. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL1))
  1071. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL2))
  1072. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_DIGITAL3))
  1073. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEIN))
  1074. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_PHONEOUT))
  1075. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_VIDEO))
  1076. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_RADIO))
  1077. COMPATIBLE_IOCTL(MIXER_WRITE(SOUND_MIXER_MONITOR))
  1078. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_MUTE)
  1079. /* SOUND_MIXER_WRITE_ENHANCE, same value as WRITE_MUTE */
  1080. /* SOUND_MIXER_WRITE_LOUD, same value as WRITE_MUTE */
  1081. COMPATIBLE_IOCTL(SOUND_MIXER_WRITE_RECSRC)
  1082. COMPATIBLE_IOCTL(SOUND_MIXER_INFO)
  1083. COMPATIBLE_IOCTL(SOUND_OLD_MIXER_INFO)
  1084. COMPATIBLE_IOCTL(SOUND_MIXER_ACCESS)
  1085. COMPATIBLE_IOCTL(SOUND_MIXER_AGC)
  1086. COMPATIBLE_IOCTL(SOUND_MIXER_3DSE)
  1087. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE1)
  1088. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE2)
  1089. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE3)
  1090. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE4)
  1091. COMPATIBLE_IOCTL(SOUND_MIXER_PRIVATE5)
  1092. COMPATIBLE_IOCTL(SOUND_MIXER_GETLEVELS)
  1093. COMPATIBLE_IOCTL(SOUND_MIXER_SETLEVELS)
  1094. COMPATIBLE_IOCTL(OSS_GETVERSION)
  1095. /* Raw devices */
  1096. COMPATIBLE_IOCTL(RAW_SETBIND)
  1097. COMPATIBLE_IOCTL(RAW_GETBIND)
  1098. /* Watchdog */
  1099. COMPATIBLE_IOCTL(WDIOC_GETSUPPORT)
  1100. COMPATIBLE_IOCTL(WDIOC_GETSTATUS)
  1101. COMPATIBLE_IOCTL(WDIOC_GETBOOTSTATUS)
  1102. COMPATIBLE_IOCTL(WDIOC_GETTEMP)
  1103. COMPATIBLE_IOCTL(WDIOC_SETOPTIONS)
  1104. COMPATIBLE_IOCTL(WDIOC_KEEPALIVE)
  1105. COMPATIBLE_IOCTL(WDIOC_SETTIMEOUT)
  1106. COMPATIBLE_IOCTL(WDIOC_GETTIMEOUT)
  1107. /* Big R */
  1108. COMPATIBLE_IOCTL(RNDGETENTCNT)
  1109. COMPATIBLE_IOCTL(RNDADDTOENTCNT)
  1110. COMPATIBLE_IOCTL(RNDGETPOOL)
  1111. COMPATIBLE_IOCTL(RNDADDENTROPY)
  1112. COMPATIBLE_IOCTL(RNDZAPENTCNT)
  1113. COMPATIBLE_IOCTL(RNDCLEARPOOL)
  1114. /* Bluetooth */
  1115. COMPATIBLE_IOCTL(HCIDEVUP)
  1116. COMPATIBLE_IOCTL(HCIDEVDOWN)
  1117. COMPATIBLE_IOCTL(HCIDEVRESET)
  1118. COMPATIBLE_IOCTL(HCIDEVRESTAT)
  1119. COMPATIBLE_IOCTL(HCIGETDEVLIST)
  1120. COMPATIBLE_IOCTL(HCIGETDEVINFO)
  1121. COMPATIBLE_IOCTL(HCIGETCONNLIST)
  1122. COMPATIBLE_IOCTL(HCIGETCONNINFO)
  1123. COMPATIBLE_IOCTL(HCIGETAUTHINFO)
  1124. COMPATIBLE_IOCTL(HCISETRAW)
  1125. COMPATIBLE_IOCTL(HCISETSCAN)
  1126. COMPATIBLE_IOCTL(HCISETAUTH)
  1127. COMPATIBLE_IOCTL(HCISETENCRYPT)
  1128. COMPATIBLE_IOCTL(HCISETPTYPE)
  1129. COMPATIBLE_IOCTL(HCISETLINKPOL)
  1130. COMPATIBLE_IOCTL(HCISETLINKMODE)
  1131. COMPATIBLE_IOCTL(HCISETACLMTU)
  1132. COMPATIBLE_IOCTL(HCISETSCOMTU)
  1133. COMPATIBLE_IOCTL(HCIBLOCKADDR)
  1134. COMPATIBLE_IOCTL(HCIUNBLOCKADDR)
  1135. COMPATIBLE_IOCTL(HCIINQUIRY)
  1136. COMPATIBLE_IOCTL(HCIUARTSETPROTO)
  1137. COMPATIBLE_IOCTL(HCIUARTGETPROTO)
  1138. COMPATIBLE_IOCTL(RFCOMMCREATEDEV)
  1139. COMPATIBLE_IOCTL(RFCOMMRELEASEDEV)
  1140. COMPATIBLE_IOCTL(RFCOMMGETDEVLIST)
  1141. COMPATIBLE_IOCTL(RFCOMMGETDEVINFO)
  1142. COMPATIBLE_IOCTL(RFCOMMSTEALDLC)
  1143. COMPATIBLE_IOCTL(BNEPCONNADD)
  1144. COMPATIBLE_IOCTL(BNEPCONNDEL)
  1145. COMPATIBLE_IOCTL(BNEPGETCONNLIST)
  1146. COMPATIBLE_IOCTL(BNEPGETCONNINFO)
  1147. COMPATIBLE_IOCTL(BNEPGETSUPPFEAT)
  1148. COMPATIBLE_IOCTL(CMTPCONNADD)
  1149. COMPATIBLE_IOCTL(CMTPCONNDEL)
  1150. COMPATIBLE_IOCTL(CMTPGETCONNLIST)
  1151. COMPATIBLE_IOCTL(CMTPGETCONNINFO)
  1152. COMPATIBLE_IOCTL(HIDPCONNADD)
  1153. COMPATIBLE_IOCTL(HIDPCONNDEL)
  1154. COMPATIBLE_IOCTL(HIDPGETCONNLIST)
  1155. COMPATIBLE_IOCTL(HIDPGETCONNINFO)
  1156. /* CAPI */
  1157. COMPATIBLE_IOCTL(CAPI_REGISTER)
  1158. COMPATIBLE_IOCTL(CAPI_GET_MANUFACTURER)
  1159. COMPATIBLE_IOCTL(CAPI_GET_VERSION)
  1160. COMPATIBLE_IOCTL(CAPI_GET_SERIAL)
  1161. COMPATIBLE_IOCTL(CAPI_GET_PROFILE)
  1162. COMPATIBLE_IOCTL(CAPI_MANUFACTURER_CMD)
  1163. COMPATIBLE_IOCTL(CAPI_GET_ERRCODE)
  1164. COMPATIBLE_IOCTL(CAPI_INSTALLED)
  1165. COMPATIBLE_IOCTL(CAPI_GET_FLAGS)
  1166. COMPATIBLE_IOCTL(CAPI_SET_FLAGS)
  1167. COMPATIBLE_IOCTL(CAPI_CLR_FLAGS)
  1168. COMPATIBLE_IOCTL(CAPI_NCCI_OPENCOUNT)
  1169. COMPATIBLE_IOCTL(CAPI_NCCI_GETUNIT)
  1170. /* Siemens Gigaset */
  1171. COMPATIBLE_IOCTL(GIGASET_REDIR)
  1172. COMPATIBLE_IOCTL(GIGASET_CONFIG)
  1173. COMPATIBLE_IOCTL(GIGASET_BRKCHARS)
  1174. COMPATIBLE_IOCTL(GIGASET_VERSION)
  1175. /* Misc. */
  1176. COMPATIBLE_IOCTL(0x41545900) /* ATYIO_CLKR */
  1177. COMPATIBLE_IOCTL(0x41545901) /* ATYIO_CLKW */
  1178. COMPATIBLE_IOCTL(PCIIOC_CONTROLLER)
  1179. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_IO)
  1180. COMPATIBLE_IOCTL(PCIIOC_MMAP_IS_MEM)
  1181. COMPATIBLE_IOCTL(PCIIOC_WRITE_COMBINE)
  1182. /* i2c */
  1183. COMPATIBLE_IOCTL(I2C_SLAVE)
  1184. COMPATIBLE_IOCTL(I2C_SLAVE_FORCE)
  1185. COMPATIBLE_IOCTL(I2C_TENBIT)
  1186. COMPATIBLE_IOCTL(I2C_PEC)
  1187. COMPATIBLE_IOCTL(I2C_RETRIES)
  1188. COMPATIBLE_IOCTL(I2C_TIMEOUT)
  1189. /* hiddev */
  1190. COMPATIBLE_IOCTL(HIDIOCGVERSION)
  1191. COMPATIBLE_IOCTL(HIDIOCAPPLICATION)
  1192. COMPATIBLE_IOCTL(HIDIOCGDEVINFO)
  1193. COMPATIBLE_IOCTL(HIDIOCGSTRING)
  1194. COMPATIBLE_IOCTL(HIDIOCINITREPORT)
  1195. COMPATIBLE_IOCTL(HIDIOCGREPORT)
  1196. COMPATIBLE_IOCTL(HIDIOCSREPORT)
  1197. COMPATIBLE_IOCTL(HIDIOCGREPORTINFO)
  1198. COMPATIBLE_IOCTL(HIDIOCGFIELDINFO)
  1199. COMPATIBLE_IOCTL(HIDIOCGUSAGE)
  1200. COMPATIBLE_IOCTL(HIDIOCSUSAGE)
  1201. COMPATIBLE_IOCTL(HIDIOCGUCODE)
  1202. COMPATIBLE_IOCTL(HIDIOCGFLAG)
  1203. COMPATIBLE_IOCTL(HIDIOCSFLAG)
  1204. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINDEX)
  1205. COMPATIBLE_IOCTL(HIDIOCGCOLLECTIONINFO)
  1206. /* dvb */
  1207. COMPATIBLE_IOCTL(AUDIO_STOP)
  1208. COMPATIBLE_IOCTL(AUDIO_PLAY)
  1209. COMPATIBLE_IOCTL(AUDIO_PAUSE)
  1210. COMPATIBLE_IOCTL(AUDIO_CONTINUE)
  1211. COMPATIBLE_IOCTL(AUDIO_SELECT_SOURCE)
  1212. COMPATIBLE_IOCTL(AUDIO_SET_MUTE)
  1213. COMPATIBLE_IOCTL(AUDIO_SET_AV_SYNC)
  1214. COMPATIBLE_IOCTL(AUDIO_SET_BYPASS_MODE)
  1215. COMPATIBLE_IOCTL(AUDIO_CHANNEL_SELECT)
  1216. COMPATIBLE_IOCTL(AUDIO_GET_STATUS)
  1217. COMPATIBLE_IOCTL(AUDIO_GET_CAPABILITIES)
  1218. COMPATIBLE_IOCTL(AUDIO_CLEAR_BUFFER)
  1219. COMPATIBLE_IOCTL(AUDIO_SET_ID)
  1220. COMPATIBLE_IOCTL(AUDIO_SET_MIXER)
  1221. COMPATIBLE_IOCTL(AUDIO_SET_STREAMTYPE)
  1222. COMPATIBLE_IOCTL(AUDIO_SET_EXT_ID)
  1223. COMPATIBLE_IOCTL(AUDIO_SET_ATTRIBUTES)
  1224. COMPATIBLE_IOCTL(AUDIO_SET_KARAOKE)
  1225. COMPATIBLE_IOCTL(DMX_START)
  1226. COMPATIBLE_IOCTL(DMX_STOP)
  1227. COMPATIBLE_IOCTL(DMX_SET_FILTER)
  1228. COMPATIBLE_IOCTL(DMX_SET_PES_FILTER)
  1229. COMPATIBLE_IOCTL(DMX_SET_BUFFER_SIZE)
  1230. COMPATIBLE_IOCTL(DMX_GET_PES_PIDS)
  1231. COMPATIBLE_IOCTL(DMX_GET_CAPS)
  1232. COMPATIBLE_IOCTL(DMX_SET_SOURCE)
  1233. COMPATIBLE_IOCTL(DMX_GET_STC)
  1234. COMPATIBLE_IOCTL(FE_GET_INFO)
  1235. COMPATIBLE_IOCTL(FE_DISEQC_RESET_OVERLOAD)
  1236. COMPATIBLE_IOCTL(FE_DISEQC_SEND_MASTER_CMD)
  1237. COMPATIBLE_IOCTL(FE_DISEQC_RECV_SLAVE_REPLY)
  1238. COMPATIBLE_IOCTL(FE_DISEQC_SEND_BURST)
  1239. COMPATIBLE_IOCTL(FE_SET_TONE)
  1240. COMPATIBLE_IOCTL(FE_SET_VOLTAGE)
  1241. COMPATIBLE_IOCTL(FE_ENABLE_HIGH_LNB_VOLTAGE)
  1242. COMPATIBLE_IOCTL(FE_READ_STATUS)
  1243. COMPATIBLE_IOCTL(FE_READ_BER)
  1244. COMPATIBLE_IOCTL(FE_READ_SIGNAL_STRENGTH)
  1245. COMPATIBLE_IOCTL(FE_READ_SNR)
  1246. COMPATIBLE_IOCTL(FE_READ_UNCORRECTED_BLOCKS)
  1247. COMPATIBLE_IOCTL(FE_SET_FRONTEND)
  1248. COMPATIBLE_IOCTL(FE_GET_FRONTEND)
  1249. COMPATIBLE_IOCTL(FE_GET_EVENT)
  1250. COMPATIBLE_IOCTL(FE_DISHNETWORK_SEND_LEGACY_CMD)
  1251. COMPATIBLE_IOCTL(VIDEO_STOP)
  1252. COMPATIBLE_IOCTL(VIDEO_PLAY)
  1253. COMPATIBLE_IOCTL(VIDEO_FREEZE)
  1254. COMPATIBLE_IOCTL(VIDEO_CONTINUE)
  1255. COMPATIBLE_IOCTL(VIDEO_SELECT_SOURCE)
  1256. COMPATIBLE_IOCTL(VIDEO_SET_BLANK)
  1257. COMPATIBLE_IOCTL(VIDEO_GET_STATUS)
  1258. COMPATIBLE_IOCTL(VIDEO_SET_DISPLAY_FORMAT)
  1259. COMPATIBLE_IOCTL(VIDEO_FAST_FORWARD)
  1260. COMPATIBLE_IOCTL(VIDEO_SLOWMOTION)
  1261. COMPATIBLE_IOCTL(VIDEO_GET_CAPABILITIES)
  1262. COMPATIBLE_IOCTL(VIDEO_CLEAR_BUFFER)
  1263. COMPATIBLE_IOCTL(VIDEO_SET_ID)
  1264. COMPATIBLE_IOCTL(VIDEO_SET_STREAMTYPE)
  1265. COMPATIBLE_IOCTL(VIDEO_SET_FORMAT)
  1266. COMPATIBLE_IOCTL(VIDEO_SET_SYSTEM)
  1267. COMPATIBLE_IOCTL(VIDEO_SET_HIGHLIGHT)
  1268. COMPATIBLE_IOCTL(VIDEO_SET_SPU)
  1269. COMPATIBLE_IOCTL(VIDEO_GET_NAVI)
  1270. COMPATIBLE_IOCTL(VIDEO_SET_ATTRIBUTES)
  1271. COMPATIBLE_IOCTL(VIDEO_GET_SIZE)
  1272. COMPATIBLE_IOCTL(VIDEO_GET_FRAME_RATE)
  1273. /* joystick */
  1274. COMPATIBLE_IOCTL(JSIOCGVERSION)
  1275. COMPATIBLE_IOCTL(JSIOCGAXES)
  1276. COMPATIBLE_IOCTL(JSIOCGBUTTONS)
  1277. COMPATIBLE_IOCTL(JSIOCGNAME(0))
  1278. #ifdef TIOCGLTC
  1279. COMPATIBLE_IOCTL(TIOCGLTC)
  1280. COMPATIBLE_IOCTL(TIOCSLTC)
  1281. #endif
  1282. #ifdef TIOCSTART
  1283. /*
  1284. * For these two we have definitions in ioctls.h and/or termios.h on
  1285. * some architectures but no actual implemention. Some applications
  1286. * like bash call them if they are defined in the headers, so we provide
  1287. * entries here to avoid syslog message spew.
  1288. */
  1289. COMPATIBLE_IOCTL(TIOCSTART)
  1290. COMPATIBLE_IOCTL(TIOCSTOP)
  1291. #endif
  1292. /* fat 'r' ioctls. These are handled by fat with ->compat_ioctl,
  1293. but we don't want warnings on other file systems. So declare
  1294. them as compatible here. */
  1295. #define VFAT_IOCTL_READDIR_BOTH32 _IOR('r', 1, struct compat_dirent[2])
  1296. #define VFAT_IOCTL_READDIR_SHORT32 _IOR('r', 2, struct compat_dirent[2])
  1297. IGNORE_IOCTL(VFAT_IOCTL_READDIR_BOTH32)
  1298. IGNORE_IOCTL(VFAT_IOCTL_READDIR_SHORT32)
  1299. #ifdef CONFIG_SPARC
  1300. /* Sparc framebuffers, handled in sbusfb_compat_ioctl() */
  1301. IGNORE_IOCTL(FBIOGTYPE)
  1302. IGNORE_IOCTL(FBIOSATTR)
  1303. IGNORE_IOCTL(FBIOGATTR)
  1304. IGNORE_IOCTL(FBIOSVIDEO)
  1305. IGNORE_IOCTL(FBIOGVIDEO)
  1306. IGNORE_IOCTL(FBIOSCURPOS)
  1307. IGNORE_IOCTL(FBIOGCURPOS)
  1308. IGNORE_IOCTL(FBIOGCURMAX)
  1309. IGNORE_IOCTL(FBIOPUTCMAP32)
  1310. IGNORE_IOCTL(FBIOGETCMAP32)
  1311. IGNORE_IOCTL(FBIOSCURSOR32)
  1312. IGNORE_IOCTL(FBIOGCURSOR32)
  1313. #endif
  1314. };
  1315. /*
  1316. * Convert common ioctl arguments based on their command number
  1317. *
  1318. * Please do not add any code in here. Instead, implement
  1319. * a compat_ioctl operation in the place that handleѕ the
  1320. * ioctl for the native case.
  1321. */
  1322. static long do_ioctl_trans(unsigned int cmd,
  1323. unsigned long arg, struct file *file)
  1324. {
  1325. void __user *argp = compat_ptr(arg);
  1326. switch (cmd) {
  1327. case PPPIOCGIDLE32:
  1328. return ppp_gidle(file, cmd, argp);
  1329. case PPPIOCSCOMPRESS32:
  1330. return ppp_scompress(file, cmd, argp);
  1331. case PPPIOCSPASS32:
  1332. case PPPIOCSACTIVE32:
  1333. return ppp_sock_fprog_ioctl_trans(file, cmd, argp);
  1334. #ifdef CONFIG_BLOCK
  1335. case SG_IO:
  1336. return sg_ioctl_trans(file, cmd, argp);
  1337. case SG_GET_REQUEST_TABLE:
  1338. return sg_grt_trans(file, cmd, argp);
  1339. case MTIOCGET32:
  1340. case MTIOCPOS32:
  1341. return mt_ioctl_trans(file, cmd, argp);
  1342. #endif
  1343. /* Serial */
  1344. case TIOCGSERIAL:
  1345. case TIOCSSERIAL:
  1346. return serial_struct_ioctl(file, cmd, argp);
  1347. /* i2c */
  1348. case I2C_FUNCS:
  1349. return w_long(file, cmd, argp);
  1350. case I2C_RDWR:
  1351. return do_i2c_rdwr_ioctl(file, cmd, argp);
  1352. case I2C_SMBUS:
  1353. return do_i2c_smbus_ioctl(file, cmd, argp);
  1354. /* Not implemented in the native kernel */
  1355. case RTC_IRQP_READ32:
  1356. case RTC_IRQP_SET32:
  1357. case RTC_EPOCH_READ32:
  1358. case RTC_EPOCH_SET32:
  1359. return rtc_ioctl(file, cmd, argp);
  1360. /* dvb */
  1361. case VIDEO_GET_EVENT:
  1362. return do_video_get_event(file, cmd, argp);
  1363. case VIDEO_STILLPICTURE:
  1364. return do_video_stillpicture(file, cmd, argp);
  1365. case VIDEO_SET_SPU_PALETTE:
  1366. return do_video_set_spu_palette(file, cmd, argp);
  1367. }
  1368. /*
  1369. * These take an integer instead of a pointer as 'arg',
  1370. * so we must not do a compat_ptr() translation.
  1371. */
  1372. switch (cmd) {
  1373. /* Big T */
  1374. case TCSBRKP:
  1375. case TIOCMIWAIT:
  1376. case TIOCSCTTY:
  1377. /* RAID */
  1378. case HOT_REMOVE_DISK:
  1379. case HOT_ADD_DISK:
  1380. case SET_DISK_FAULTY:
  1381. case SET_BITMAP_FILE:
  1382. /* Big K */
  1383. case KDSIGACCEPT:
  1384. case KIOCSOUND:
  1385. case KDMKTONE:
  1386. case KDSETMODE:
  1387. case KDSKBMODE:
  1388. case KDSKBMETA:
  1389. case KDSKBLED:
  1390. case KDSETLED:
  1391. return vfs_ioctl(file, cmd, arg);
  1392. }
  1393. return -ENOIOCTLCMD;
  1394. }
  1395. static int compat_ioctl_check_table(unsigned int xcmd)
  1396. {
  1397. int i;
  1398. const int max = ARRAY_SIZE(ioctl_pointer) - 1;
  1399. BUILD_BUG_ON(max >= (1 << 16));
  1400. /* guess initial offset into table, assuming a
  1401. normalized distribution */
  1402. i = ((xcmd >> 16) * max) >> 16;
  1403. /* do linear search up first, until greater or equal */
  1404. while (ioctl_pointer[i] < xcmd && i < max)
  1405. i++;
  1406. /* then do linear search down */
  1407. while (ioctl_pointer[i] > xcmd && i > 0)
  1408. i--;
  1409. return ioctl_pointer[i] == xcmd;
  1410. }
  1411. COMPAT_SYSCALL_DEFINE3(ioctl, unsigned int, fd, unsigned int, cmd,
  1412. compat_ulong_t, arg32)
  1413. {
  1414. unsigned long arg = arg32;
  1415. struct fd f = fdget(fd);
  1416. int error = -EBADF;
  1417. if (!f.file)
  1418. goto out;
  1419. /* RED-PEN how should LSM module know it's handling 32bit? */
  1420. error = security_file_ioctl(f.file, cmd, arg);
  1421. if (error)
  1422. goto out_fput;
  1423. /*
  1424. * To allow the compat_ioctl handlers to be self contained
  1425. * we need to check the common ioctls here first.
  1426. * Just handle them with the standard handlers below.
  1427. */
  1428. switch (cmd) {
  1429. case FIOCLEX:
  1430. case FIONCLEX:
  1431. case FIONBIO:
  1432. case FIOASYNC:
  1433. case FIOQSIZE:
  1434. break;
  1435. #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
  1436. case FS_IOC_RESVSP_32:
  1437. case FS_IOC_RESVSP64_32:
  1438. error = compat_ioctl_preallocate(f.file, compat_ptr(arg));
  1439. goto out_fput;
  1440. #else
  1441. case FS_IOC_RESVSP:
  1442. case FS_IOC_RESVSP64:
  1443. error = ioctl_preallocate(f.file, compat_ptr(arg));
  1444. goto out_fput;
  1445. #endif
  1446. case FICLONE:
  1447. case FICLONERANGE:
  1448. case FIDEDUPERANGE:
  1449. goto do_ioctl;
  1450. case FIBMAP:
  1451. case FIGETBSZ:
  1452. case FIONREAD:
  1453. if (S_ISREG(file_inode(f.file)->i_mode))
  1454. break;
  1455. /*FALL THROUGH*/
  1456. default:
  1457. if (f.file->f_op->compat_ioctl) {
  1458. error = f.file->f_op->compat_ioctl(f.file, cmd, arg);
  1459. if (error != -ENOIOCTLCMD)
  1460. goto out_fput;
  1461. }
  1462. if (!f.file->f_op->unlocked_ioctl)
  1463. goto do_ioctl;
  1464. break;
  1465. }
  1466. if (compat_ioctl_check_table(XFORM(cmd)))
  1467. goto found_handler;
  1468. error = do_ioctl_trans(cmd, arg, f.file);
  1469. if (error == -ENOIOCTLCMD)
  1470. error = -ENOTTY;
  1471. goto out_fput;
  1472. found_handler:
  1473. arg = (unsigned long)compat_ptr(arg);
  1474. do_ioctl:
  1475. error = do_vfs_ioctl(f.file, fd, cmd, arg);
  1476. out_fput:
  1477. fdput(f);
  1478. out:
  1479. return error;
  1480. }
  1481. static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
  1482. {
  1483. unsigned int a, b;
  1484. a = *(unsigned int *)p;
  1485. b = *(unsigned int *)q;
  1486. if (a > b)
  1487. return 1;
  1488. if (a < b)
  1489. return -1;
  1490. return 0;
  1491. }
  1492. static int __init init_sys32_ioctl(void)
  1493. {
  1494. sort(ioctl_pointer, ARRAY_SIZE(ioctl_pointer), sizeof(*ioctl_pointer),
  1495. init_sys32_ioctl_cmp, NULL);
  1496. return 0;
  1497. }
  1498. __initcall(init_sys32_ioctl);