blob: 16c3027074a22f6aea08e0157a5848f824e08afd [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001/* SPDX-License-Identifier: GPL-2.0 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
Andy Lutomirski5180e3e2016-03-22 14:24:43 -07009#include <linux/types.h>
10
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#ifdef CONFIG_COMPAT
12
13#include <linux/stat.h>
14#include <linux/param.h> /* for HZ */
15#include <linux/sem.h>
Arnd Bergmann2dceba12009-11-06 08:09:03 +000016#include <linux/socket.h>
17#include <linux/if.h>
Chris Metcalfbe84cb42011-05-09 13:12:30 -040018#include <linux/fs.h>
Stephen Rothwell45e96832011-05-24 13:28:54 +100019#include <linux/aio_abi.h> /* for aio_context_t */
Matt Redfearnfde9fc72018-02-19 16:55:06 +000020#include <linux/uaccess.h>
Heiko Carstensf5b972e2014-03-20 15:30:14 +010021#include <linux/unistd.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022
23#include <asm/compat.h>
24#include <asm/siginfo.h>
David Howells3f2e05e2006-10-02 14:12:31 +010025#include <asm/signal.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
H. J. Lu45e87782012-02-10 14:04:27 -080027#ifndef COMPAT_USE_64BIT_TIME
28#define COMPAT_USE_64BIT_TIME 0
29#endif
30
Al Viro46836612012-11-23 09:12:59 -050031#ifndef __SC_DELOUSE
Al Viro4f59c712017-07-08 11:40:39 -040032#define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v))
Al Viro46836612012-11-23 09:12:59 -050033#endif
34
Heiko Carstens217f4432014-02-26 10:56:20 +010035#define COMPAT_SYSCALL_DEFINE0(name) \
36 asmlinkage long compat_sys_##name(void)
37
Al Viro46836612012-11-23 09:12:59 -050038#define COMPAT_SYSCALL_DEFINE1(name, ...) \
39 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
40#define COMPAT_SYSCALL_DEFINE2(name, ...) \
41 COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
42#define COMPAT_SYSCALL_DEFINE3(name, ...) \
43 COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
44#define COMPAT_SYSCALL_DEFINE4(name, ...) \
45 COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
46#define COMPAT_SYSCALL_DEFINE5(name, ...) \
47 COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
48#define COMPAT_SYSCALL_DEFINE6(name, ...) \
49 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
50
Al Viro46836612012-11-23 09:12:59 -050051#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
Andi Kleen83460ec2013-11-12 15:08:36 -080052 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
53 __attribute__((alias(__stringify(compat_SyS##name)))); \
Al Viro07fe6e02013-01-21 15:03:44 -050054 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
Sergei Trofimovichf9597f22013-09-11 14:23:28 -070055 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\
Al Viro07fe6e02013-01-21 15:03:44 -050056 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
Al Viro46836612012-11-23 09:12:59 -050057 { \
Al Viro07fe6e02013-01-21 15:03:44 -050058 return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
Al Viro46836612012-11-23 09:12:59 -050059 } \
Al Viro07fe6e02013-01-21 15:03:44 -050060 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
Al Viro46836612012-11-23 09:12:59 -050061
Al Viro9b064fc2012-12-14 13:49:35 -050062#ifndef compat_user_stack_pointer
63#define compat_user_stack_pointer() current_user_stack_pointer()
64#endif
Al Viro90268432012-12-14 14:47:53 -050065#ifndef compat_sigaltstack /* we'll need that for MIPS */
66typedef struct compat_sigaltstack {
67 compat_uptr_t ss_sp;
68 int ss_flags;
69 compat_size_t ss_size;
70} compat_stack_t;
71#endif
Al Viro90268432012-12-14 14:47:53 -050072
Linus Torvalds1da177e2005-04-16 15:20:36 -070073#define compat_jiffies_to_clock_t(x) \
74 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
75
Stephen Rothwell202e5972005-09-06 15:16:40 -070076typedef __compat_uid32_t compat_uid_t;
77typedef __compat_gid32_t compat_gid_t;
78
Heiko Carstens932602e2014-03-04 16:07:52 +010079typedef compat_ulong_t compat_aio_context_t;
80
Christoph Hellwig5d0e5282010-03-10 15:21:13 -080081struct compat_sel_arg_struct;
Linus Torvalds1da177e2005-04-16 15:20:36 -070082struct rusage;
83
Chris Metcalf4800a5b2011-05-17 14:41:06 -040084struct compat_itimerspec {
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 struct compat_timespec it_interval;
86 struct compat_timespec it_value;
87};
88
89struct compat_utimbuf {
90 compat_time_t actime;
91 compat_time_t modtime;
92};
93
94struct compat_itimerval {
95 struct compat_timeval it_interval;
96 struct compat_timeval it_value;
97};
98
Al Viro54ad9c42017-06-07 09:42:37 +010099struct itimerval;
100int get_compat_itimerval(struct itimerval *, const struct compat_itimerval __user *);
101int put_compat_itimerval(struct compat_itimerval __user *, const struct itimerval *);
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103struct compat_tms {
104 compat_clock_t tms_utime;
105 compat_clock_t tms_stime;
106 compat_clock_t tms_cutime;
107 compat_clock_t tms_cstime;
108};
109
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800110struct compat_timex {
111 compat_uint_t modes;
112 compat_long_t offset;
113 compat_long_t freq;
114 compat_long_t maxerror;
115 compat_long_t esterror;
116 compat_int_t status;
117 compat_long_t constant;
118 compat_long_t precision;
119 compat_long_t tolerance;
120 struct compat_timeval time;
121 compat_long_t tick;
122 compat_long_t ppsfreq;
123 compat_long_t jitter;
124 compat_int_t shift;
125 compat_long_t stabil;
126 compat_long_t jitcnt;
127 compat_long_t calcnt;
128 compat_long_t errcnt;
129 compat_long_t stbcnt;
Roman Zippel153b5d02008-05-01 04:34:37 -0700130 compat_int_t tai;
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800131
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400132 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
133 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
134 compat_int_t:32; compat_int_t:32; compat_int_t:32;
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800135};
136
Al Viro3a4d44b2017-06-07 09:42:34 +0100137struct timex;
138int compat_get_timex(struct timex *, const struct compat_timex __user *);
139int compat_put_timex(struct compat_timex __user *, const struct timex *);
140
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
142
143typedef struct {
144 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
145} compat_sigset_t;
146
Al Viro08d32fe2012-12-25 18:38:15 -0500147struct compat_sigaction {
David Howells2a148692013-03-19 14:00:53 +0000148#ifndef __ARCH_HAS_IRIX_SIGACTION
Al Viro08d32fe2012-12-25 18:38:15 -0500149 compat_uptr_t sa_handler;
150 compat_ulong_t sa_flags;
151#else
David Howells2a148692013-03-19 14:00:53 +0000152 compat_uint_t sa_flags;
Al Viro08d32fe2012-12-25 18:38:15 -0500153 compat_uptr_t sa_handler;
154#endif
155#ifdef __ARCH_HAS_SA_RESTORER
156 compat_uptr_t sa_restorer;
157#endif
158 compat_sigset_t sa_mask __packed;
159};
Al Viro08d32fe2012-12-25 18:38:15 -0500160
Al Virob713da62017-07-09 15:53:17 -0400161typedef union compat_sigval {
162 compat_int_t sival_int;
163 compat_uptr_t sival_ptr;
164} compat_sigval_t;
165
166typedef struct compat_siginfo {
167 int si_signo;
168#ifndef __ARCH_HAS_SWAPPED_SIGINFO
169 int si_errno;
170 int si_code;
171#else
172 int si_code;
173 int si_errno;
174#endif
175
176 union {
177 int _pad[128/sizeof(int) - 3];
178
179 /* kill() */
180 struct {
181 compat_pid_t _pid; /* sender's pid */
182 __compat_uid32_t _uid; /* sender's uid */
183 } _kill;
184
185 /* POSIX.1b timers */
186 struct {
187 compat_timer_t _tid; /* timer id */
188 int _overrun; /* overrun count */
189 compat_sigval_t _sigval; /* same as below */
190 } _timer;
191
192 /* POSIX.1b signals */
193 struct {
194 compat_pid_t _pid; /* sender's pid */
195 __compat_uid32_t _uid; /* sender's uid */
196 compat_sigval_t _sigval;
197 } _rt;
198
199 /* SIGCHLD */
200 struct {
201 compat_pid_t _pid; /* which child */
202 __compat_uid32_t _uid; /* sender's uid */
203 int _status; /* exit code */
204 compat_clock_t _utime;
205 compat_clock_t _stime;
206 } _sigchld;
207
208#ifdef CONFIG_X86_X32_ABI
209 /* SIGCHLD (x32 version) */
210 struct {
211 compat_pid_t _pid; /* which child */
212 __compat_uid32_t _uid; /* sender's uid */
213 int _status; /* exit code */
214 compat_s64 _utime;
215 compat_s64 _stime;
216 } _sigchld_x32;
217#endif
218
219 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
220 struct {
221 compat_uptr_t _addr; /* faulting insn/memory ref. */
222#ifdef __ARCH_SI_TRAPNO
223 int _trapno; /* TRAP # which caused the signal */
224#endif
Al Virob713da62017-07-09 15:53:17 -0400225 union {
Eric W. Biedermanb68a68d2017-07-31 10:08:59 -0500226 /*
227 * used when si_code=BUS_MCEERR_AR or
228 * used when si_code=BUS_MCEERR_AO
229 */
230 short int _addr_lsb; /* Valid LSB of the reported address. */
Al Virob713da62017-07-09 15:53:17 -0400231 /* used when si_code=SEGV_BNDERR */
232 struct {
Eric W. Biederman859d8802018-03-06 00:20:25 -0600233 compat_uptr_t _dummy_bnd;
Al Virob713da62017-07-09 15:53:17 -0400234 compat_uptr_t _lower;
235 compat_uptr_t _upper;
236 } _addr_bnd;
237 /* used when si_code=SEGV_PKUERR */
Eric W. Biedermanb68a68d2017-07-31 10:08:59 -0500238 struct {
Eric W. Biederman859d8802018-03-06 00:20:25 -0600239 compat_uptr_t _dummy_pkey;
Eric W. Biedermanb68a68d2017-07-31 10:08:59 -0500240 u32 _pkey;
241 } _addr_pkey;
Al Virob713da62017-07-09 15:53:17 -0400242 };
243 } _sigfault;
244
245 /* SIGPOLL */
246 struct {
247 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
248 int _fd;
249 } _sigpoll;
250
251 struct {
252 compat_uptr_t _call_addr; /* calling user insn */
253 int _syscall; /* triggering system call number */
254 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
255 } _sigsys;
256 } _sifields;
257} compat_siginfo_t;
258
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800259/*
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800260 * These functions operate on 32- or 64-bit specs depending on
H. Peter Anvin81993e82014-02-01 18:54:11 -0800261 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments.
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800262 */
263extern int compat_get_timespec(struct timespec *, const void __user *);
264extern int compat_put_timespec(const struct timespec *, void __user *);
265extern int compat_get_timeval(struct timeval *, const void __user *);
266extern int compat_put_timeval(const struct timeval *, void __user *);
Deepa Dinamanif59dd9c2017-06-24 11:45:02 -0700267extern int compat_get_timespec64(struct timespec64 *, const void __user *);
268extern int compat_put_timespec64(const struct timespec64 *, void __user *);
Deepa Dinamanid5b7ffb2017-06-24 11:45:03 -0700269extern int get_compat_itimerspec64(struct itimerspec64 *its,
270 const struct compat_itimerspec __user *uits);
271extern int put_compat_itimerspec64(const struct itimerspec64 *its,
272 struct compat_itimerspec __user *uits);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273
274struct compat_iovec {
275 compat_uptr_t iov_base;
276 compat_size_t iov_len;
277};
278
279struct compat_rlimit {
280 compat_ulong_t rlim_cur;
281 compat_ulong_t rlim_max;
282};
283
284struct compat_rusage {
285 struct compat_timeval ru_utime;
286 struct compat_timeval ru_stime;
287 compat_long_t ru_maxrss;
288 compat_long_t ru_ixrss;
289 compat_long_t ru_idrss;
290 compat_long_t ru_isrss;
291 compat_long_t ru_minflt;
292 compat_long_t ru_majflt;
293 compat_long_t ru_nswap;
294 compat_long_t ru_inblock;
295 compat_long_t ru_oublock;
296 compat_long_t ru_msgsnd;
297 compat_long_t ru_msgrcv;
298 compat_long_t ru_nsignals;
299 compat_long_t ru_nvcsw;
300 compat_long_t ru_nivcsw;
301};
302
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400303extern int put_compat_rusage(const struct rusage *,
304 struct compat_rusage __user *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700305
306struct compat_siginfo;
307
308extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
309 struct compat_siginfo __user *, int,
310 struct compat_rusage __user *);
311
312struct compat_dirent {
313 u32 d_ino;
314 compat_off_t d_off;
315 u16 d_reclen;
316 char d_name[256];
317};
318
Christoph Hellwig2b1c6bd2008-11-28 10:09:09 +0100319struct compat_ustat {
320 compat_daddr_t f_tfree;
321 compat_ino_t f_tinode;
322 char f_fname[6];
323 char f_fpack[6];
324};
325
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326#define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
327
328typedef struct compat_sigevent {
329 compat_sigval_t sigev_value;
330 compat_int_t sigev_signo;
331 compat_int_t sigev_notify;
332 union {
333 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
334 compat_int_t _tid;
335
336 struct {
337 compat_uptr_t _function;
338 compat_uptr_t _attribute;
339 } _sigev_thread;
340 } _sigev_un;
341} compat_sigevent_t;
342
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000343struct compat_ifmap {
344 compat_ulong_t mem_start;
345 compat_ulong_t mem_end;
346 unsigned short base_addr;
347 unsigned char irq;
348 unsigned char dma;
349 unsigned char port;
350};
351
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400352struct compat_if_settings {
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800353 unsigned int type; /* Type of physical device or protocol */
354 unsigned int size; /* Size of the data allocated by the caller */
355 compat_uptr_t ifs_ifsu; /* union of pointers */
356};
357
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000358struct compat_ifreq {
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800359 union {
360 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
361 } ifr_ifrn;
362 union {
363 struct sockaddr ifru_addr;
364 struct sockaddr ifru_dstaddr;
365 struct sockaddr ifru_broadaddr;
366 struct sockaddr ifru_netmask;
367 struct sockaddr ifru_hwaddr;
368 short ifru_flags;
369 compat_int_t ifru_ivalue;
370 compat_int_t ifru_mtu;
371 struct compat_ifmap ifru_map;
372 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000373 char ifru_newname[IFNAMSIZ];
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800374 compat_caddr_t ifru_data;
375 struct compat_if_settings ifru_settings;
376 } ifr_ifru;
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000377};
378
379struct compat_ifconf {
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400380 compat_int_t ifc_len; /* size of buffer */
381 compat_caddr_t ifcbuf;
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000382};
383
Ingo Molnar34f192c2006-03-27 01:16:24 -0800384struct compat_robust_list {
385 compat_uptr_t next;
386};
387
388struct compat_robust_list_head {
389 struct compat_robust_list list;
390 compat_long_t futex_offset;
391 compat_uptr_t list_op_pending;
392};
393
Al Viro495dfbf2012-12-25 19:09:45 -0500394#ifdef CONFIG_COMPAT_OLD_SIGACTION
395struct compat_old_sigaction {
396 compat_uptr_t sa_handler;
397 compat_old_sigset_t sa_mask;
398 compat_ulong_t sa_flags;
399 compat_uptr_t sa_restorer;
400};
401#endif
402
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200403struct compat_keyctl_kdf_params {
404 compat_uptr_t hashname;
405 compat_uptr_t otherinfo;
406 __u32 otherinfolen;
407 __u32 __spare[8];
408};
409
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400410struct compat_statfs;
411struct compat_statfs64;
412struct compat_old_linux_dirent;
413struct compat_linux_dirent;
414struct linux_dirent64;
415struct compat_msghdr;
416struct compat_mmsghdr;
417struct compat_sysinfo;
418struct compat_sysctl_args;
419struct compat_kexec_segment;
420struct compat_mq_attr;
Chris Metcalf48b25c42012-03-15 13:13:38 -0400421struct compat_msgbuf;
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400422
Ingo Molnar34f192c2006-03-27 01:16:24 -0800423extern void compat_exit_robust_list(struct task_struct *curr);
424
425asmlinkage long
426compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
427 compat_size_t len);
428asmlinkage long
Al Viroba46df92006-10-10 22:46:07 +0100429compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
Ingo Molnar34f192c2006-03-27 01:16:24 -0800430 compat_size_t __user *len_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431
Al Viro56e41d32013-01-21 23:15:25 -0500432asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
Al Viro0e65a812013-02-03 14:36:44 -0500433asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
434asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
435asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
Will Deacon05ba3f12012-07-30 14:42:43 -0700436 compat_ssize_t msgsz, int msgflg);
Al Viro0e65a812013-02-03 14:36:44 -0500437asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
Heiko Carstens291fdb02014-03-04 12:39:03 +0100438 compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg);
Chris Metcalf48b25c42012-03-15 13:13:38 -0400439long compat_sys_msgctl(int first, int second, void __user *uptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440long compat_sys_shmctl(int first, int second, void __user *uptr);
441long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
442 unsigned nsems, const struct compat_timespec __user *timeout);
443asmlinkage long compat_sys_keyctl(u32 option,
444 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
Christoph Hellwig2b1c6bd2008-11-28 10:09:09 +0100445asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700446
Heiko Carstensdfd948e2014-01-29 14:05:44 -0800447asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd,
448 const struct compat_iovec __user *vec, compat_ulong_t vlen);
449asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd,
450 const struct compat_iovec __user *vec, compat_ulong_t vlen);
451asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
Gerd Hoffmannf3554f42009-04-02 16:59:23 -0700452 const struct compat_iovec __user *vec,
Heiko Carstensdfd948e2014-01-29 14:05:44 -0800453 compat_ulong_t vlen, u32 pos_low, u32 pos_high);
454asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
Gerd Hoffmannf3554f42009-04-02 16:59:23 -0700455 const struct compat_iovec __user *vec,
Heiko Carstensdfd948e2014-01-29 14:05:44 -0800456 compat_ulong_t vlen, u32 pos_low, u32 pos_high);
Milosz Tanskif17d8b32016-03-03 16:03:59 +0100457asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd,
458 const struct compat_iovec __user *vec,
Christoph Hellwigddef7ed2017-07-06 18:58:37 +0200459 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
Milosz Tanskif17d8b32016-03-03 16:03:59 +0100460asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
461 const struct compat_iovec __user *vec,
Christoph Hellwigddef7ed2017-07-06 18:58:37 +0200462 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
Heiko Carstens378a10f2014-03-05 10:43:51 +0100463
464#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
465asmlinkage long compat_sys_preadv64(unsigned long fd,
466 const struct compat_iovec __user *vec,
467 unsigned long vlen, loff_t pos);
468#endif
469
470#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
471asmlinkage long compat_sys_pwritev64(unsigned long fd,
472 const struct compat_iovec __user *vec,
473 unsigned long vlen, loff_t pos);
474#endif
475
Christoph Hellwigddef7ed2017-07-06 18:58:37 +0200476#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2
477asmlinkage long compat_sys_readv64v2(unsigned long fd,
478 const struct compat_iovec __user *vec,
479 unsigned long vlen, loff_t pos, rwf_t flags);
480#endif
481
482#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2
483asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
484 const struct compat_iovec __user *vec,
485 unsigned long vlen, loff_t pos, rwf_t flags);
486#endif
487
Stephan Springle5fbf672014-01-30 17:56:23 +0100488asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489
Al Viro38b983b2012-09-30 13:38:55 -0400490asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
491 const compat_uptr_t __user *envp);
David Drysdale51f39a12014-12-12 16:57:29 -0800492asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
493 const compat_uptr_t __user *argv,
494 const compat_uptr_t __user *envp, int flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495
496asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
497 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
498 struct compat_timeval __user *tvp);
499
Christoph Hellwig5d0e5282010-03-10 15:21:13 -0800500asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
501
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100502asmlinkage long compat_sys_wait4(compat_pid_t pid,
Al Viro7d61c452008-03-29 03:09:28 +0000503 compat_uint_t __user *stat_addr, int options,
504 struct compat_rusage __user *ru);
Thomas Gleixnerc202f292008-01-30 13:30:08 +0100505
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
507
Al Viro1e1fc132017-05-30 00:29:38 -0400508#define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509
Stephen Rothwell5fa38392006-10-28 10:38:46 -0700510long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 unsigned long bitmap_size);
512long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
513 unsigned long bitmap_size);
Eric W. Biederman212a36a2017-07-31 17:15:31 -0500514int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from);
Al Viroce395962013-10-13 17:23:53 -0400515int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516int get_compat_sigevent(struct sigevent *event,
517 const struct compat_sigevent __user *u_event);
Thomas Gleixner62ab4502009-04-04 21:01:06 +0000518long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
519 struct compat_siginfo __user *uinfo);
Al Viro495dfbf2012-12-25 19:09:45 -0500520#ifdef CONFIG_COMPAT_OLD_SIGACTION
521asmlinkage long compat_sys_sigaction(int sig,
522 const struct compat_old_sigaction __user *act,
523 struct compat_old_sigaction __user *oact);
524#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525
Andrew Morton643a6542006-02-11 17:55:52 -0800526static inline int compat_timeval_compare(struct compat_timeval *lhs,
527 struct compat_timeval *rhs)
528{
529 if (lhs->tv_sec < rhs->tv_sec)
530 return -1;
531 if (lhs->tv_sec > rhs->tv_sec)
532 return 1;
533 return lhs->tv_usec - rhs->tv_usec;
534}
535
536static inline int compat_timespec_compare(struct compat_timespec *lhs,
537 struct compat_timespec *rhs)
538{
539 if (lhs->tv_sec < rhs->tv_sec)
540 return -1;
541 if (lhs->tv_sec > rhs->tv_sec)
542 return 1;
543 return lhs->tv_nsec - rhs->tv_nsec;
544}
545
Christoph Hellwigb418da12008-10-15 22:02:06 -0700546asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
547 struct timezone __user *tz);
548asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
549 struct timezone __user *tz);
550
Stephen Rothwell3158e942006-03-26 01:37:29 -0800551asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
552
Al Viro3968cf62017-09-03 21:45:17 -0400553extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
Matt Redfearnfde9fc72018-02-19 16:55:06 +0000554
555/*
556 * Defined inline such that size can be compile time constant, which avoids
557 * CONFIG_HARDENED_USERCOPY complaining about copies from task_struct
558 */
559static inline int
560put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
561 unsigned int size)
562{
563 /* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */
564#ifdef __BIG_ENDIAN
565 compat_sigset_t v;
566 switch (_NSIG_WORDS) {
567 case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
568 case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
569 case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
570 case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
571 }
572 return copy_to_user(compat, &v, size) ? -EFAULT : 0;
573#else
574 return copy_to_user(compat, set, size) ? -EFAULT : 0;
575#endif
576}
Andi Kleenbebfa102006-06-26 13:56:52 +0200577
Stephen Rothwell3fd59392006-11-02 22:07:24 -0800578asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
579 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
580 const compat_ulong_t __user *new_nodes);
581
Roland McGrath032d82d2008-01-30 13:31:47 +0100582extern int compat_ptrace_request(struct task_struct *child,
583 compat_long_t request,
584 compat_ulong_t addr, compat_ulong_t data);
585
Roland McGrathc269f192008-01-30 13:31:48 +0100586extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
587 compat_ulong_t addr, compat_ulong_t data);
588asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
589 compat_long_t addr, compat_long_t data);
Roland McGrathc269f192008-01-30 13:31:48 +0100590
Heiko Carstensd8d14bd2014-01-29 14:05:46 -0800591asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800592/*
593 * epoll (fs/eventpoll.c) compat bits follow ...
594 */
Al Viro35280bd2013-02-24 14:52:17 -0500595struct epoll_event; /* fortunately, this one is fixed-layout */
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800596asmlinkage long compat_sys_epoll_pwait(int epfd,
Al Viro35280bd2013-02-24 14:52:17 -0500597 struct epoll_event __user *events,
Davide Libenzif6dfb4f2007-03-07 20:41:21 -0800598 int maxevents, int timeout,
599 const compat_sigset_t __user *sigmask,
600 compat_size_t sigsetsize);
601
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400602asmlinkage long compat_sys_utime(const char __user *filename,
603 struct compat_utimbuf __user *t);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400604asmlinkage long compat_sys_utimensat(unsigned int dfd,
605 const char __user *filename,
606 struct compat_timespec __user *t,
607 int flags);
Stephen Rothwell97416ce2007-05-09 02:32:35 -0700608
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400609asmlinkage long compat_sys_time(compat_time_t __user *tloc);
610asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
Stephen Rothwell140ff8b2007-05-14 13:47:47 +1000611asmlinkage long compat_sys_signalfd(int ufd,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400612 const compat_sigset_t __user *sigmask,
613 compat_size_t sigsetsize);
Davide Libenzi4d672e72008-02-04 22:27:26 -0800614asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
615 const struct compat_itimerspec __user *utmr,
616 struct compat_itimerspec __user *otmr);
617asmlinkage long compat_sys_timerfd_gettime(int ufd,
618 struct compat_itimerspec __user *otmr);
Stephen Rothwell140ff8b2007-05-14 13:47:47 +1000619
Heiko Carstens2f2728f2014-03-04 17:18:23 +0100620asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages,
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100621 __u32 __user *pages,
622 const int __user *nodes,
623 int __user *status,
624 int flags);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400625asmlinkage long compat_sys_futimesat(unsigned int dfd,
626 const char __user *filename,
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100627 struct compat_timeval __user *t);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400628asmlinkage long compat_sys_utimes(const char __user *filename,
629 struct compat_timeval __user *t);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400630asmlinkage long compat_sys_newstat(const char __user *filename,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400631 struct compat_stat __user *statbuf);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400632asmlinkage long compat_sys_newlstat(const char __user *filename,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400633 struct compat_stat __user *statbuf);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400634asmlinkage long compat_sys_newfstatat(unsigned int dfd,
635 const char __user *filename,
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100636 struct compat_stat __user *statbuf,
637 int flag);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400638asmlinkage long compat_sys_newfstat(unsigned int fd,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400639 struct compat_stat __user *statbuf);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400640asmlinkage long compat_sys_statfs(const char __user *pathname,
641 struct compat_statfs __user *buf);
642asmlinkage long compat_sys_fstatfs(unsigned int fd,
643 struct compat_statfs __user *buf);
644asmlinkage long compat_sys_statfs64(const char __user *pathname,
645 compat_size_t sz,
646 struct compat_statfs64 __user *buf);
647asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
648 struct compat_statfs64 __user *buf);
649asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
Heiko Carstens932602e2014-03-04 16:07:52 +0100650 compat_ulong_t arg);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400651asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
Heiko Carstens932602e2014-03-04 16:07:52 +0100652 compat_ulong_t arg);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400653asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
Heiko Carstens932602e2014-03-04 16:07:52 +0100654asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id,
655 compat_long_t min_nr,
656 compat_long_t nr,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400657 struct io_event __user *events,
658 struct compat_timespec __user *timeout);
Heiko Carstens932602e2014-03-04 16:07:52 +0100659asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400660 u32 __user *iocb);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400661asmlinkage long compat_sys_mount(const char __user *dev_name,
662 const char __user *dir_name,
Heiko Carstens932602e2014-03-04 16:07:52 +0100663 const char __user *type, compat_ulong_t flags,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400664 const void __user *data);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400665asmlinkage long compat_sys_old_readdir(unsigned int fd,
666 struct compat_old_linux_dirent __user *,
667 unsigned int count);
668asmlinkage long compat_sys_getdents(unsigned int fd,
669 struct compat_linux_dirent __user *dirent,
670 unsigned int count);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400671asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
672 unsigned int nr_segs, unsigned int flags);
673asmlinkage long compat_sys_open(const char __user *filename, int flags,
Al Viroa218d0f2011-11-21 14:59:34 -0500674 umode_t mode);
Al Virof482e1b2012-12-25 20:24:38 -0500675asmlinkage long compat_sys_openat(int dfd, const char __user *filename,
Al Viroa218d0f2011-11-21 14:59:34 -0500676 int flags, umode_t mode);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400677asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
678 struct file_handle __user *handle,
679 int flags);
Al Viro3f6d0782013-02-24 13:49:08 -0500680asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
681asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400682asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
683 compat_ulong_t __user *outp,
684 compat_ulong_t __user *exp,
685 struct compat_timespec __user *tsp,
686 void __user *sig);
687asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
688 unsigned int nfds,
689 struct compat_timespec __user *tsp,
690 const compat_sigset_t __user *sigmask,
691 compat_size_t sigsetsize);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400692asmlinkage long compat_sys_signalfd4(int ufd,
693 const compat_sigset_t __user *sigmask,
694 compat_size_t sigsetsize, int flags);
695asmlinkage long compat_sys_get_mempolicy(int __user *policy,
696 compat_ulong_t __user *nmask,
697 compat_ulong_t maxnode,
698 compat_ulong_t addr,
699 compat_ulong_t flags);
700asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
701 compat_ulong_t maxnode);
702asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
703 compat_ulong_t mode,
704 compat_ulong_t __user *nmask,
705 compat_ulong_t maxnode, compat_ulong_t flags);
706
707asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
708 char __user *optval, unsigned int optlen);
709asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
710 unsigned flags);
Chris Metcalf507c5f12011-06-27 16:18:07 -0700711asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
712 unsigned vlen, unsigned int flags);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400713asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
714 unsigned int flags);
Heiko Carstens3a49a0f2014-03-04 17:09:57 +0100715asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400716 unsigned flags);
Heiko Carstens3a49a0f2014-03-04 17:09:57 +0100717asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400718 unsigned flags, struct sockaddr __user *addr,
719 int __user *addrlen);
720asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
721 unsigned vlen, unsigned int flags,
722 struct compat_timespec __user *timeout);
723asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
724 struct compat_timespec __user *rmtp);
725asmlinkage long compat_sys_getitimer(int which,
726 struct compat_itimerval __user *it);
727asmlinkage long compat_sys_setitimer(int which,
728 struct compat_itimerval __user *in,
729 struct compat_itimerval __user *out);
730asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
731asmlinkage long compat_sys_setrlimit(unsigned int resource,
732 struct compat_rlimit __user *rlim);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400733asmlinkage long compat_sys_getrlimit(unsigned int resource,
734 struct compat_rlimit __user *rlim);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400735asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
736asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
737 unsigned int len,
738 compat_ulong_t __user *user_mask_ptr);
739asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
740 unsigned int len,
741 compat_ulong_t __user *user_mask_ptr);
742asmlinkage long compat_sys_timer_create(clockid_t which_clock,
743 struct compat_sigevent __user *timer_event_spec,
744 timer_t __user *created_timer_id);
745asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
746 struct compat_itimerspec __user *new,
747 struct compat_itimerspec __user *old);
748asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
749 struct compat_itimerspec __user *setting);
750asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
751 struct compat_timespec __user *tp);
752asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
753 struct compat_timespec __user *tp);
754asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
755 struct compat_timex __user *tp);
756asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
757 struct compat_timespec __user *tp);
758asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
759 struct compat_timespec __user *rqtp,
760 struct compat_timespec __user *rmtp);
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400761asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400762 struct compat_siginfo __user *uinfo,
763 struct compat_timespec __user *uts, compat_size_t sigsetsize);
764asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
765 compat_size_t sigsetsize);
Al Viro322a56c2012-12-25 13:32:58 -0500766asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set,
767 compat_sigset_t __user *oset,
768 compat_size_t sigsetsize);
Al Virofe9c1db2012-12-25 14:31:38 -0500769asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
770 compat_size_t sigsetsize);
Al Viro08d32fe2012-12-25 18:38:15 -0500771#ifndef CONFIG_ODD_RT_SIGACTION
Al Viro08d32fe2012-12-25 18:38:15 -0500772asmlinkage long compat_sys_rt_sigaction(int,
773 const struct compat_sigaction __user *,
774 struct compat_sigaction __user *,
775 compat_size_t);
776#endif
Al Viro75907d42012-12-25 15:19:12 -0500777asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
778 struct compat_siginfo __user *uinfo);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400779asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
780asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
Heiko Carstens932602e2014-03-04 16:07:52 +0100781 compat_ulong_t arg);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400782asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
783 struct compat_timespec __user *utime, u32 __user *uaddr2,
784 u32 val3);
785asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
786 char __user *optval, int __user *optlen);
Heiko Carstensca2c4052014-03-04 17:13:42 +0100787asmlinkage long compat_sys_kexec_load(compat_ulong_t entry,
788 compat_ulong_t nr_segments,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400789 struct compat_kexec_segment __user *,
Heiko Carstensca2c4052014-03-04 17:13:42 +0100790 compat_ulong_t flags);
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400791asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
792 const struct compat_mq_attr __user *u_mqstat,
793 struct compat_mq_attr __user *u_omqstat);
794asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
795 const struct compat_sigevent __user *u_notification);
796asmlinkage long compat_sys_mq_open(const char __user *u_name,
797 int oflag, compat_mode_t mode,
798 struct compat_mq_attr __user *u_attr);
799asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
800 const char __user *u_msg_ptr,
Heiko Carstens8eee9092014-03-04 16:19:16 +0100801 compat_size_t msg_len, unsigned int msg_prio,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400802 const struct compat_timespec __user *u_abs_timeout);
803asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
804 char __user *u_msg_ptr,
Heiko Carstens8eee9092014-03-04 16:19:16 +0100805 compat_size_t msg_len, unsigned int __user *u_msg_prio,
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400806 const struct compat_timespec __user *u_abs_timeout);
807asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
808asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100809
Jeff Moyerb8373362010-05-26 14:44:25 -0700810extern ssize_t compat_rw_copy_check_uvector(int type,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400811 const struct compat_iovec __user *uvector,
812 unsigned long nr_segs,
Jeff Moyerb8373362010-05-26 14:44:25 -0700813 unsigned long fast_segs, struct iovec *fast_pointer,
Christopher Yeohac34ebb2012-05-31 16:26:42 -0700814 struct iovec **ret_pointer);
H. Peter Anvinc41d68a2010-09-07 16:16:18 -0700815
816extern void __user *compat_alloc_user_space(unsigned long len);
817
Chris Metcalfa67ba432011-12-01 12:54:31 -0500818asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid,
819 const struct compat_iovec __user *lvec,
Heiko Carstens2f2728f2014-03-04 17:18:23 +0100820 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
821 compat_ulong_t riovcnt, compat_ulong_t flags);
Chris Metcalfa67ba432011-12-01 12:54:31 -0500822asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
823 const struct compat_iovec __user *lvec,
Heiko Carstens2f2728f2014-03-04 17:18:23 +0100824 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
825 compat_ulong_t riovcnt, compat_ulong_t flags);
Chris Metcalfa67ba432011-12-01 12:54:31 -0500826
Catalin Marinas8f9c0112012-09-19 12:01:52 +0100827asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
828 compat_off_t __user *offset, compat_size_t count);
Al Viro19f4fc32013-02-24 02:17:03 -0500829asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
830 compat_loff_t __user *offset, compat_size_t count);
Al Viro90268432012-12-14 14:47:53 -0500831asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
832 compat_stack_t __user *uoss_ptr);
833
Catalin Marinase9fb8b72015-01-06 16:48:36 +0000834#ifdef __ARCH_WANT_SYS_SIGPENDING
835asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set);
836#endif
837
838#ifdef __ARCH_WANT_SYS_SIGPROCMASK
839asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset,
840 compat_old_sigset_t __user *oset);
841#endif
842
Al Viro90268432012-12-14 14:47:53 -0500843int compat_restore_altstack(const compat_stack_t __user *uss);
Al Viroc40702c2012-11-20 14:24:26 -0500844int __compat_save_altstack(compat_stack_t __user *, unsigned long);
Al Virobd1c149a2013-09-01 20:35:01 +0100845#define compat_save_altstack_ex(uss, sp) do { \
846 compat_stack_t __user *__uss = uss; \
847 struct task_struct *t = current; \
848 put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &__uss->ss_sp); \
Stas Sergeev441398d2017-02-27 14:27:25 -0800849 put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
Al Virobd1c149a2013-09-01 20:35:01 +0100850 put_user_ex(t->sas_ss_size, &__uss->ss_size); \
Stas Sergeev441398d2017-02-27 14:27:25 -0800851 if (t->sas_ss_flags & SS_AUTODISARM) \
852 sas_ss_reset(t); \
Al Virobd1c149a2013-09-01 20:35:01 +0100853} while (0);
Catalin Marinas8f9c0112012-09-19 12:01:52 +0100854
Catalin Marinas0ad50c32012-12-17 16:01:45 -0800855asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
856 struct compat_timespec __user *interval);
857
Al Viro91c2e0b2013-03-05 20:10:59 -0500858asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
859 int, const char __user *);
Andy Lutomirski5180e3e2016-03-22 14:24:43 -0700860
Kyle Huey79170fd2017-03-20 01:16:24 -0700861asmlinkage long compat_sys_arch_prctl(int option, unsigned long arg2);
862
Andy Lutomirski5180e3e2016-03-22 14:24:43 -0700863/*
864 * For most but not all architectures, "am I in a compat syscall?" and
865 * "am I a compat task?" are the same question. For architectures on which
866 * they aren't the same question, arch code can override in_compat_syscall.
867 */
868
869#ifndef in_compat_syscall
870static inline bool in_compat_syscall(void) { return is_compat_task(); }
871#endif
872
Frederic Weisbeckercd19c362017-01-31 04:09:27 +0100873/**
874 * ns_to_compat_timeval - Compat version of ns_to_timeval
875 * @nsec: the nanoseconds value to be converted
876 *
877 * Returns the compat_timeval representation of the nsec parameter.
878 */
879static inline struct compat_timeval ns_to_compat_timeval(s64 nsec)
880{
881 struct timeval tv;
882 struct compat_timeval ctv;
883
884 tv = ns_to_timeval(nsec);
885 ctv.tv_sec = tv.tv_sec;
886 ctv.tv_usec = tv.tv_usec;
887
888 return ctv;
889}
890
891#else /* !CONFIG_COMPAT */
Linus Torvalds3c761ea2012-02-26 09:44:55 -0800892
893#define is_compat_task() (0)
Andy Lutomirski5180e3e2016-03-22 14:24:43 -0700894static inline bool in_compat_syscall(void) { return false; }
Linus Torvalds3c761ea2012-02-26 09:44:55 -0800895
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896#endif /* CONFIG_COMPAT */
Andy Lutomirski5180e3e2016-03-22 14:24:43 -0700897
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898#endif /* _LINUX_COMPAT_H */