compat_ioctl.c 42 KB

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