compat.h 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _LINUX_COMPAT_H
  3. #define _LINUX_COMPAT_H
  4. /*
  5. * These are the type definitions for the architecture specific
  6. * syscall compatibility layer.
  7. */
  8. #include <linux/types.h>
  9. #ifdef CONFIG_COMPAT
  10. #include <linux/stat.h>
  11. #include <linux/param.h> /* for HZ */
  12. #include <linux/sem.h>
  13. #include <linux/socket.h>
  14. #include <linux/if.h>
  15. #include <linux/fs.h>
  16. #include <linux/aio_abi.h> /* for aio_context_t */
  17. #include <linux/unistd.h>
  18. #include <asm/compat.h>
  19. #include <asm/siginfo.h>
  20. #include <asm/signal.h>
  21. #ifndef COMPAT_USE_64BIT_TIME
  22. #define COMPAT_USE_64BIT_TIME 0
  23. #endif
  24. #ifndef __SC_DELOUSE
  25. #define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v))
  26. #endif
  27. #define COMPAT_SYSCALL_DEFINE0(name) \
  28. asmlinkage long compat_sys_##name(void)
  29. #define COMPAT_SYSCALL_DEFINE1(name, ...) \
  30. COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
  31. #define COMPAT_SYSCALL_DEFINE2(name, ...) \
  32. COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
  33. #define COMPAT_SYSCALL_DEFINE3(name, ...) \
  34. COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
  35. #define COMPAT_SYSCALL_DEFINE4(name, ...) \
  36. COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
  37. #define COMPAT_SYSCALL_DEFINE5(name, ...) \
  38. COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
  39. #define COMPAT_SYSCALL_DEFINE6(name, ...) \
  40. COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
  41. #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
  42. asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
  43. __attribute__((alias(__stringify(compat_SyS##name)))); \
  44. static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
  45. asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\
  46. asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
  47. { \
  48. return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
  49. } \
  50. static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
  51. #ifndef compat_user_stack_pointer
  52. #define compat_user_stack_pointer() current_user_stack_pointer()
  53. #endif
  54. #ifndef compat_sigaltstack /* we'll need that for MIPS */
  55. typedef struct compat_sigaltstack {
  56. compat_uptr_t ss_sp;
  57. int ss_flags;
  58. compat_size_t ss_size;
  59. } compat_stack_t;
  60. #endif
  61. #define compat_jiffies_to_clock_t(x) \
  62. (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
  63. typedef __compat_uid32_t compat_uid_t;
  64. typedef __compat_gid32_t compat_gid_t;
  65. typedef compat_ulong_t compat_aio_context_t;
  66. struct compat_sel_arg_struct;
  67. struct rusage;
  68. struct compat_itimerspec {
  69. struct compat_timespec it_interval;
  70. struct compat_timespec it_value;
  71. };
  72. struct compat_utimbuf {
  73. compat_time_t actime;
  74. compat_time_t modtime;
  75. };
  76. struct compat_itimerval {
  77. struct compat_timeval it_interval;
  78. struct compat_timeval it_value;
  79. };
  80. struct itimerval;
  81. int get_compat_itimerval(struct itimerval *, const struct compat_itimerval __user *);
  82. int put_compat_itimerval(struct compat_itimerval __user *, const struct itimerval *);
  83. struct compat_tms {
  84. compat_clock_t tms_utime;
  85. compat_clock_t tms_stime;
  86. compat_clock_t tms_cutime;
  87. compat_clock_t tms_cstime;
  88. };
  89. struct compat_timex {
  90. compat_uint_t modes;
  91. compat_long_t offset;
  92. compat_long_t freq;
  93. compat_long_t maxerror;
  94. compat_long_t esterror;
  95. compat_int_t status;
  96. compat_long_t constant;
  97. compat_long_t precision;
  98. compat_long_t tolerance;
  99. struct compat_timeval time;
  100. compat_long_t tick;
  101. compat_long_t ppsfreq;
  102. compat_long_t jitter;
  103. compat_int_t shift;
  104. compat_long_t stabil;
  105. compat_long_t jitcnt;
  106. compat_long_t calcnt;
  107. compat_long_t errcnt;
  108. compat_long_t stbcnt;
  109. compat_int_t tai;
  110. compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
  111. compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
  112. compat_int_t:32; compat_int_t:32; compat_int_t:32;
  113. };
  114. struct timex;
  115. int compat_get_timex(struct timex *, const struct compat_timex __user *);
  116. int compat_put_timex(struct compat_timex __user *, const struct timex *);
  117. #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
  118. typedef struct {
  119. compat_sigset_word sig[_COMPAT_NSIG_WORDS];
  120. } compat_sigset_t;
  121. struct compat_sigaction {
  122. #ifndef __ARCH_HAS_IRIX_SIGACTION
  123. compat_uptr_t sa_handler;
  124. compat_ulong_t sa_flags;
  125. #else
  126. compat_uint_t sa_flags;
  127. compat_uptr_t sa_handler;
  128. #endif
  129. #ifdef __ARCH_HAS_SA_RESTORER
  130. compat_uptr_t sa_restorer;
  131. #endif
  132. compat_sigset_t sa_mask __packed;
  133. };
  134. typedef union compat_sigval {
  135. compat_int_t sival_int;
  136. compat_uptr_t sival_ptr;
  137. } compat_sigval_t;
  138. typedef struct compat_siginfo {
  139. int si_signo;
  140. #ifndef __ARCH_HAS_SWAPPED_SIGINFO
  141. int si_errno;
  142. int si_code;
  143. #else
  144. int si_code;
  145. int si_errno;
  146. #endif
  147. union {
  148. int _pad[128/sizeof(int) - 3];
  149. /* kill() */
  150. struct {
  151. compat_pid_t _pid; /* sender's pid */
  152. __compat_uid32_t _uid; /* sender's uid */
  153. } _kill;
  154. /* POSIX.1b timers */
  155. struct {
  156. compat_timer_t _tid; /* timer id */
  157. int _overrun; /* overrun count */
  158. compat_sigval_t _sigval; /* same as below */
  159. } _timer;
  160. /* POSIX.1b signals */
  161. struct {
  162. compat_pid_t _pid; /* sender's pid */
  163. __compat_uid32_t _uid; /* sender's uid */
  164. compat_sigval_t _sigval;
  165. } _rt;
  166. /* SIGCHLD */
  167. struct {
  168. compat_pid_t _pid; /* which child */
  169. __compat_uid32_t _uid; /* sender's uid */
  170. int _status; /* exit code */
  171. compat_clock_t _utime;
  172. compat_clock_t _stime;
  173. } _sigchld;
  174. #ifdef CONFIG_X86_X32_ABI
  175. /* SIGCHLD (x32 version) */
  176. struct {
  177. compat_pid_t _pid; /* which child */
  178. __compat_uid32_t _uid; /* sender's uid */
  179. int _status; /* exit code */
  180. compat_s64 _utime;
  181. compat_s64 _stime;
  182. } _sigchld_x32;
  183. #endif
  184. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
  185. struct {
  186. compat_uptr_t _addr; /* faulting insn/memory ref. */
  187. #ifdef __ARCH_SI_TRAPNO
  188. int _trapno; /* TRAP # which caused the signal */
  189. #endif
  190. union {
  191. /*
  192. * used when si_code=BUS_MCEERR_AR or
  193. * used when si_code=BUS_MCEERR_AO
  194. */
  195. short int _addr_lsb; /* Valid LSB of the reported address. */
  196. /* used when si_code=SEGV_BNDERR */
  197. struct {
  198. compat_uptr_t _dummy_bnd;
  199. compat_uptr_t _lower;
  200. compat_uptr_t _upper;
  201. } _addr_bnd;
  202. /* used when si_code=SEGV_PKUERR */
  203. struct {
  204. compat_uptr_t _dummy_pkey;
  205. u32 _pkey;
  206. } _addr_pkey;
  207. };
  208. } _sigfault;
  209. /* SIGPOLL */
  210. struct {
  211. compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  212. int _fd;
  213. } _sigpoll;
  214. struct {
  215. compat_uptr_t _call_addr; /* calling user insn */
  216. int _syscall; /* triggering system call number */
  217. unsigned int _arch; /* AUDIT_ARCH_* of syscall */
  218. } _sigsys;
  219. } _sifields;
  220. } compat_siginfo_t;
  221. /*
  222. * These functions operate on 32- or 64-bit specs depending on
  223. * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments.
  224. */
  225. extern int compat_get_timespec(struct timespec *, const void __user *);
  226. extern int compat_put_timespec(const struct timespec *, void __user *);
  227. extern int compat_get_timeval(struct timeval *, const void __user *);
  228. extern int compat_put_timeval(const struct timeval *, void __user *);
  229. extern int compat_get_timespec64(struct timespec64 *, const void __user *);
  230. extern int compat_put_timespec64(const struct timespec64 *, void __user *);
  231. extern int get_compat_itimerspec64(struct itimerspec64 *its,
  232. const struct compat_itimerspec __user *uits);
  233. extern int put_compat_itimerspec64(const struct itimerspec64 *its,
  234. struct compat_itimerspec __user *uits);
  235. struct compat_iovec {
  236. compat_uptr_t iov_base;
  237. compat_size_t iov_len;
  238. };
  239. struct compat_rlimit {
  240. compat_ulong_t rlim_cur;
  241. compat_ulong_t rlim_max;
  242. };
  243. struct compat_rusage {
  244. struct compat_timeval ru_utime;
  245. struct compat_timeval ru_stime;
  246. compat_long_t ru_maxrss;
  247. compat_long_t ru_ixrss;
  248. compat_long_t ru_idrss;
  249. compat_long_t ru_isrss;
  250. compat_long_t ru_minflt;
  251. compat_long_t ru_majflt;
  252. compat_long_t ru_nswap;
  253. compat_long_t ru_inblock;
  254. compat_long_t ru_oublock;
  255. compat_long_t ru_msgsnd;
  256. compat_long_t ru_msgrcv;
  257. compat_long_t ru_nsignals;
  258. compat_long_t ru_nvcsw;
  259. compat_long_t ru_nivcsw;
  260. };
  261. extern int put_compat_rusage(const struct rusage *,
  262. struct compat_rusage __user *);
  263. struct compat_siginfo;
  264. extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
  265. struct compat_siginfo __user *, int,
  266. struct compat_rusage __user *);
  267. struct compat_dirent {
  268. u32 d_ino;
  269. compat_off_t d_off;
  270. u16 d_reclen;
  271. char d_name[256];
  272. };
  273. struct compat_ustat {
  274. compat_daddr_t f_tfree;
  275. compat_ino_t f_tinode;
  276. char f_fname[6];
  277. char f_fpack[6];
  278. };
  279. #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
  280. typedef struct compat_sigevent {
  281. compat_sigval_t sigev_value;
  282. compat_int_t sigev_signo;
  283. compat_int_t sigev_notify;
  284. union {
  285. compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
  286. compat_int_t _tid;
  287. struct {
  288. compat_uptr_t _function;
  289. compat_uptr_t _attribute;
  290. } _sigev_thread;
  291. } _sigev_un;
  292. } compat_sigevent_t;
  293. struct compat_ifmap {
  294. compat_ulong_t mem_start;
  295. compat_ulong_t mem_end;
  296. unsigned short base_addr;
  297. unsigned char irq;
  298. unsigned char dma;
  299. unsigned char port;
  300. };
  301. struct compat_if_settings {
  302. unsigned int type; /* Type of physical device or protocol */
  303. unsigned int size; /* Size of the data allocated by the caller */
  304. compat_uptr_t ifs_ifsu; /* union of pointers */
  305. };
  306. struct compat_ifreq {
  307. union {
  308. char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
  309. } ifr_ifrn;
  310. union {
  311. struct sockaddr ifru_addr;
  312. struct sockaddr ifru_dstaddr;
  313. struct sockaddr ifru_broadaddr;
  314. struct sockaddr ifru_netmask;
  315. struct sockaddr ifru_hwaddr;
  316. short ifru_flags;
  317. compat_int_t ifru_ivalue;
  318. compat_int_t ifru_mtu;
  319. struct compat_ifmap ifru_map;
  320. char ifru_slave[IFNAMSIZ]; /* Just fits the size */
  321. char ifru_newname[IFNAMSIZ];
  322. compat_caddr_t ifru_data;
  323. struct compat_if_settings ifru_settings;
  324. } ifr_ifru;
  325. };
  326. struct compat_ifconf {
  327. compat_int_t ifc_len; /* size of buffer */
  328. compat_caddr_t ifcbuf;
  329. };
  330. struct compat_robust_list {
  331. compat_uptr_t next;
  332. };
  333. struct compat_robust_list_head {
  334. struct compat_robust_list list;
  335. compat_long_t futex_offset;
  336. compat_uptr_t list_op_pending;
  337. };
  338. #ifdef CONFIG_COMPAT_OLD_SIGACTION
  339. struct compat_old_sigaction {
  340. compat_uptr_t sa_handler;
  341. compat_old_sigset_t sa_mask;
  342. compat_ulong_t sa_flags;
  343. compat_uptr_t sa_restorer;
  344. };
  345. #endif
  346. struct compat_keyctl_kdf_params {
  347. compat_uptr_t hashname;
  348. compat_uptr_t otherinfo;
  349. __u32 otherinfolen;
  350. __u32 __spare[8];
  351. };
  352. struct compat_statfs;
  353. struct compat_statfs64;
  354. struct compat_old_linux_dirent;
  355. struct compat_linux_dirent;
  356. struct linux_dirent64;
  357. struct compat_msghdr;
  358. struct compat_mmsghdr;
  359. struct compat_sysinfo;
  360. struct compat_sysctl_args;
  361. struct compat_kexec_segment;
  362. struct compat_mq_attr;
  363. struct compat_msgbuf;
  364. extern void compat_exit_robust_list(struct task_struct *curr);
  365. asmlinkage long
  366. compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
  367. compat_size_t len);
  368. asmlinkage long
  369. compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
  370. compat_size_t __user *len_ptr);
  371. asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
  372. asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
  373. asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
  374. asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
  375. compat_ssize_t msgsz, int msgflg);
  376. asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
  377. compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg);
  378. long compat_sys_msgctl(int first, int second, void __user *uptr);
  379. long compat_sys_shmctl(int first, int second, void __user *uptr);
  380. long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
  381. unsigned nsems, const struct compat_timespec __user *timeout);
  382. asmlinkage long compat_sys_keyctl(u32 option,
  383. u32 arg2, u32 arg3, u32 arg4, u32 arg5);
  384. asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
  385. asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd,
  386. const struct compat_iovec __user *vec, compat_ulong_t vlen);
  387. asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd,
  388. const struct compat_iovec __user *vec, compat_ulong_t vlen);
  389. asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
  390. const struct compat_iovec __user *vec,
  391. compat_ulong_t vlen, u32 pos_low, u32 pos_high);
  392. asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
  393. const struct compat_iovec __user *vec,
  394. compat_ulong_t vlen, u32 pos_low, u32 pos_high);
  395. asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd,
  396. const struct compat_iovec __user *vec,
  397. compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
  398. asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
  399. const struct compat_iovec __user *vec,
  400. compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
  401. #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
  402. asmlinkage long compat_sys_preadv64(unsigned long fd,
  403. const struct compat_iovec __user *vec,
  404. unsigned long vlen, loff_t pos);
  405. #endif
  406. #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
  407. asmlinkage long compat_sys_pwritev64(unsigned long fd,
  408. const struct compat_iovec __user *vec,
  409. unsigned long vlen, loff_t pos);
  410. #endif
  411. #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2
  412. asmlinkage long compat_sys_readv64v2(unsigned long fd,
  413. const struct compat_iovec __user *vec,
  414. unsigned long vlen, loff_t pos, rwf_t flags);
  415. #endif
  416. #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2
  417. asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
  418. const struct compat_iovec __user *vec,
  419. unsigned long vlen, loff_t pos, rwf_t flags);
  420. #endif
  421. asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
  422. asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
  423. const compat_uptr_t __user *envp);
  424. asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
  425. const compat_uptr_t __user *argv,
  426. const compat_uptr_t __user *envp, int flags);
  427. asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
  428. compat_ulong_t __user *outp, compat_ulong_t __user *exp,
  429. struct compat_timeval __user *tvp);
  430. asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
  431. asmlinkage long compat_sys_wait4(compat_pid_t pid,
  432. compat_uint_t __user *stat_addr, int options,
  433. struct compat_rusage __user *ru);
  434. #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
  435. #define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG)
  436. long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
  437. unsigned long bitmap_size);
  438. long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
  439. unsigned long bitmap_size);
  440. int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from);
  441. int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from);
  442. int get_compat_sigevent(struct sigevent *event,
  443. const struct compat_sigevent __user *u_event);
  444. long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
  445. struct compat_siginfo __user *uinfo);
  446. #ifdef CONFIG_COMPAT_OLD_SIGACTION
  447. asmlinkage long compat_sys_sigaction(int sig,
  448. const struct compat_old_sigaction __user *act,
  449. struct compat_old_sigaction __user *oact);
  450. #endif
  451. static inline int compat_timeval_compare(struct compat_timeval *lhs,
  452. struct compat_timeval *rhs)
  453. {
  454. if (lhs->tv_sec < rhs->tv_sec)
  455. return -1;
  456. if (lhs->tv_sec > rhs->tv_sec)
  457. return 1;
  458. return lhs->tv_usec - rhs->tv_usec;
  459. }
  460. static inline int compat_timespec_compare(struct compat_timespec *lhs,
  461. struct compat_timespec *rhs)
  462. {
  463. if (lhs->tv_sec < rhs->tv_sec)
  464. return -1;
  465. if (lhs->tv_sec > rhs->tv_sec)
  466. return 1;
  467. return lhs->tv_nsec - rhs->tv_nsec;
  468. }
  469. asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
  470. struct timezone __user *tz);
  471. asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
  472. struct timezone __user *tz);
  473. asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
  474. extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
  475. extern int put_compat_sigset(compat_sigset_t __user *compat,
  476. const sigset_t *set, unsigned int size);
  477. asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
  478. compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
  479. const compat_ulong_t __user *new_nodes);
  480. extern int compat_ptrace_request(struct task_struct *child,
  481. compat_long_t request,
  482. compat_ulong_t addr, compat_ulong_t data);
  483. extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
  484. compat_ulong_t addr, compat_ulong_t data);
  485. asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
  486. compat_long_t addr, compat_long_t data);
  487. asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
  488. /*
  489. * epoll (fs/eventpoll.c) compat bits follow ...
  490. */
  491. struct epoll_event; /* fortunately, this one is fixed-layout */
  492. asmlinkage long compat_sys_epoll_pwait(int epfd,
  493. struct epoll_event __user *events,
  494. int maxevents, int timeout,
  495. const compat_sigset_t __user *sigmask,
  496. compat_size_t sigsetsize);
  497. asmlinkage long compat_sys_utime(const char __user *filename,
  498. struct compat_utimbuf __user *t);
  499. asmlinkage long compat_sys_utimensat(unsigned int dfd,
  500. const char __user *filename,
  501. struct compat_timespec __user *t,
  502. int flags);
  503. asmlinkage long compat_sys_time(compat_time_t __user *tloc);
  504. asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
  505. asmlinkage long compat_sys_signalfd(int ufd,
  506. const compat_sigset_t __user *sigmask,
  507. compat_size_t sigsetsize);
  508. asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
  509. const struct compat_itimerspec __user *utmr,
  510. struct compat_itimerspec __user *otmr);
  511. asmlinkage long compat_sys_timerfd_gettime(int ufd,
  512. struct compat_itimerspec __user *otmr);
  513. asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages,
  514. __u32 __user *pages,
  515. const int __user *nodes,
  516. int __user *status,
  517. int flags);
  518. asmlinkage long compat_sys_futimesat(unsigned int dfd,
  519. const char __user *filename,
  520. struct compat_timeval __user *t);
  521. asmlinkage long compat_sys_utimes(const char __user *filename,
  522. struct compat_timeval __user *t);
  523. asmlinkage long compat_sys_newstat(const char __user *filename,
  524. struct compat_stat __user *statbuf);
  525. asmlinkage long compat_sys_newlstat(const char __user *filename,
  526. struct compat_stat __user *statbuf);
  527. asmlinkage long compat_sys_newfstatat(unsigned int dfd,
  528. const char __user *filename,
  529. struct compat_stat __user *statbuf,
  530. int flag);
  531. asmlinkage long compat_sys_newfstat(unsigned int fd,
  532. struct compat_stat __user *statbuf);
  533. asmlinkage long compat_sys_statfs(const char __user *pathname,
  534. struct compat_statfs __user *buf);
  535. asmlinkage long compat_sys_fstatfs(unsigned int fd,
  536. struct compat_statfs __user *buf);
  537. asmlinkage long compat_sys_statfs64(const char __user *pathname,
  538. compat_size_t sz,
  539. struct compat_statfs64 __user *buf);
  540. asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
  541. struct compat_statfs64 __user *buf);
  542. asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
  543. compat_ulong_t arg);
  544. asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
  545. compat_ulong_t arg);
  546. asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
  547. asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id,
  548. compat_long_t min_nr,
  549. compat_long_t nr,
  550. struct io_event __user *events,
  551. struct compat_timespec __user *timeout);
  552. asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
  553. u32 __user *iocb);
  554. asmlinkage long compat_sys_mount(const char __user *dev_name,
  555. const char __user *dir_name,
  556. const char __user *type, compat_ulong_t flags,
  557. const void __user *data);
  558. asmlinkage long compat_sys_old_readdir(unsigned int fd,
  559. struct compat_old_linux_dirent __user *,
  560. unsigned int count);
  561. asmlinkage long compat_sys_getdents(unsigned int fd,
  562. struct compat_linux_dirent __user *dirent,
  563. unsigned int count);
  564. asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
  565. unsigned int nr_segs, unsigned int flags);
  566. asmlinkage long compat_sys_open(const char __user *filename, int flags,
  567. umode_t mode);
  568. asmlinkage long compat_sys_openat(int dfd, const char __user *filename,
  569. int flags, umode_t mode);
  570. asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
  571. struct file_handle __user *handle,
  572. int flags);
  573. asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
  574. asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
  575. asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
  576. compat_ulong_t __user *outp,
  577. compat_ulong_t __user *exp,
  578. struct compat_timespec __user *tsp,
  579. void __user *sig);
  580. asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
  581. unsigned int nfds,
  582. struct compat_timespec __user *tsp,
  583. const compat_sigset_t __user *sigmask,
  584. compat_size_t sigsetsize);
  585. asmlinkage long compat_sys_signalfd4(int ufd,
  586. const compat_sigset_t __user *sigmask,
  587. compat_size_t sigsetsize, int flags);
  588. asmlinkage long compat_sys_get_mempolicy(int __user *policy,
  589. compat_ulong_t __user *nmask,
  590. compat_ulong_t maxnode,
  591. compat_ulong_t addr,
  592. compat_ulong_t flags);
  593. asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
  594. compat_ulong_t maxnode);
  595. asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
  596. compat_ulong_t mode,
  597. compat_ulong_t __user *nmask,
  598. compat_ulong_t maxnode, compat_ulong_t flags);
  599. asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
  600. char __user *optval, unsigned int optlen);
  601. asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
  602. unsigned flags);
  603. asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
  604. unsigned vlen, unsigned int flags);
  605. asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
  606. unsigned int flags);
  607. asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
  608. unsigned flags);
  609. asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len,
  610. unsigned flags, struct sockaddr __user *addr,
  611. int __user *addrlen);
  612. asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
  613. unsigned vlen, unsigned int flags,
  614. struct compat_timespec __user *timeout);
  615. asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
  616. struct compat_timespec __user *rmtp);
  617. asmlinkage long compat_sys_getitimer(int which,
  618. struct compat_itimerval __user *it);
  619. asmlinkage long compat_sys_setitimer(int which,
  620. struct compat_itimerval __user *in,
  621. struct compat_itimerval __user *out);
  622. asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
  623. asmlinkage long compat_sys_setrlimit(unsigned int resource,
  624. struct compat_rlimit __user *rlim);
  625. asmlinkage long compat_sys_getrlimit(unsigned int resource,
  626. struct compat_rlimit __user *rlim);
  627. asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
  628. asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
  629. unsigned int len,
  630. compat_ulong_t __user *user_mask_ptr);
  631. asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
  632. unsigned int len,
  633. compat_ulong_t __user *user_mask_ptr);
  634. asmlinkage long compat_sys_timer_create(clockid_t which_clock,
  635. struct compat_sigevent __user *timer_event_spec,
  636. timer_t __user *created_timer_id);
  637. asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
  638. struct compat_itimerspec __user *new,
  639. struct compat_itimerspec __user *old);
  640. asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
  641. struct compat_itimerspec __user *setting);
  642. asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
  643. struct compat_timespec __user *tp);
  644. asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
  645. struct compat_timespec __user *tp);
  646. asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
  647. struct compat_timex __user *tp);
  648. asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
  649. struct compat_timespec __user *tp);
  650. asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
  651. struct compat_timespec __user *rqtp,
  652. struct compat_timespec __user *rmtp);
  653. asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
  654. struct compat_siginfo __user *uinfo,
  655. struct compat_timespec __user *uts, compat_size_t sigsetsize);
  656. asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
  657. compat_size_t sigsetsize);
  658. asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set,
  659. compat_sigset_t __user *oset,
  660. compat_size_t sigsetsize);
  661. asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
  662. compat_size_t sigsetsize);
  663. #ifndef CONFIG_ODD_RT_SIGACTION
  664. asmlinkage long compat_sys_rt_sigaction(int,
  665. const struct compat_sigaction __user *,
  666. struct compat_sigaction __user *,
  667. compat_size_t);
  668. #endif
  669. asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
  670. struct compat_siginfo __user *uinfo);
  671. asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
  672. asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
  673. compat_ulong_t arg);
  674. asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
  675. struct compat_timespec __user *utime, u32 __user *uaddr2,
  676. u32 val3);
  677. asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
  678. char __user *optval, int __user *optlen);
  679. asmlinkage long compat_sys_kexec_load(compat_ulong_t entry,
  680. compat_ulong_t nr_segments,
  681. struct compat_kexec_segment __user *,
  682. compat_ulong_t flags);
  683. asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
  684. const struct compat_mq_attr __user *u_mqstat,
  685. struct compat_mq_attr __user *u_omqstat);
  686. asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
  687. const struct compat_sigevent __user *u_notification);
  688. asmlinkage long compat_sys_mq_open(const char __user *u_name,
  689. int oflag, compat_mode_t mode,
  690. struct compat_mq_attr __user *u_attr);
  691. asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
  692. const char __user *u_msg_ptr,
  693. compat_size_t msg_len, unsigned int msg_prio,
  694. const struct compat_timespec __user *u_abs_timeout);
  695. asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
  696. char __user *u_msg_ptr,
  697. compat_size_t msg_len, unsigned int __user *u_msg_prio,
  698. const struct compat_timespec __user *u_abs_timeout);
  699. asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
  700. asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
  701. extern ssize_t compat_rw_copy_check_uvector(int type,
  702. const struct compat_iovec __user *uvector,
  703. unsigned long nr_segs,
  704. unsigned long fast_segs, struct iovec *fast_pointer,
  705. struct iovec **ret_pointer);
  706. extern void __user *compat_alloc_user_space(unsigned long len);
  707. asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid,
  708. const struct compat_iovec __user *lvec,
  709. compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
  710. compat_ulong_t riovcnt, compat_ulong_t flags);
  711. asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
  712. const struct compat_iovec __user *lvec,
  713. compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
  714. compat_ulong_t riovcnt, compat_ulong_t flags);
  715. asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
  716. compat_off_t __user *offset, compat_size_t count);
  717. asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
  718. compat_loff_t __user *offset, compat_size_t count);
  719. asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
  720. compat_stack_t __user *uoss_ptr);
  721. #ifdef __ARCH_WANT_SYS_SIGPENDING
  722. asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set);
  723. #endif
  724. #ifdef __ARCH_WANT_SYS_SIGPROCMASK
  725. asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset,
  726. compat_old_sigset_t __user *oset);
  727. #endif
  728. int compat_restore_altstack(const compat_stack_t __user *uss);
  729. int __compat_save_altstack(compat_stack_t __user *, unsigned long);
  730. #define compat_save_altstack_ex(uss, sp) do { \
  731. compat_stack_t __user *__uss = uss; \
  732. struct task_struct *t = current; \
  733. put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &__uss->ss_sp); \
  734. put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
  735. put_user_ex(t->sas_ss_size, &__uss->ss_size); \
  736. if (t->sas_ss_flags & SS_AUTODISARM) \
  737. sas_ss_reset(t); \
  738. } while (0);
  739. asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
  740. struct compat_timespec __user *interval);
  741. asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
  742. int, const char __user *);
  743. asmlinkage long compat_sys_arch_prctl(int option, unsigned long arg2);
  744. /*
  745. * For most but not all architectures, "am I in a compat syscall?" and
  746. * "am I a compat task?" are the same question. For architectures on which
  747. * they aren't the same question, arch code can override in_compat_syscall.
  748. */
  749. #ifndef in_compat_syscall
  750. static inline bool in_compat_syscall(void) { return is_compat_task(); }
  751. #endif
  752. /**
  753. * ns_to_compat_timeval - Compat version of ns_to_timeval
  754. * @nsec: the nanoseconds value to be converted
  755. *
  756. * Returns the compat_timeval representation of the nsec parameter.
  757. */
  758. static inline struct compat_timeval ns_to_compat_timeval(s64 nsec)
  759. {
  760. struct timeval tv;
  761. struct compat_timeval ctv;
  762. tv = ns_to_timeval(nsec);
  763. ctv.tv_sec = tv.tv_sec;
  764. ctv.tv_usec = tv.tv_usec;
  765. return ctv;
  766. }
  767. #else /* !CONFIG_COMPAT */
  768. #define is_compat_task() (0)
  769. static inline bool in_compat_syscall(void) { return false; }
  770. #endif /* CONFIG_COMPAT */
  771. #endif /* _LINUX_COMPAT_H */