compat.h 27 KB

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