compat_ioctl.c 42 KB

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