blob: 2d85ec5cfda24fe0c62ac26829fbd8a28d33431b [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
Dominik Brodowski7303e302018-04-05 11:53:03 +020027#ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
28/*
29 * It may be useful for an architecture to override the definitions of the
30 * COMPAT_SYSCALL_DEFINE0 and COMPAT_SYSCALL_DEFINEx() macros, in particular
31 * to use a different calling convention for syscalls. To allow for that,
32 + the prototypes for the compat_sys_*() functions below will *not* be included
33 * if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
34 */
35#include <asm/syscall_wrapper.h>
36#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
37
H. J. Lu45e87782012-02-10 14:04:27 -080038#ifndef COMPAT_USE_64BIT_TIME
39#define COMPAT_USE_64BIT_TIME 0
40#endif
41
Al Viro46836612012-11-23 09:12:59 -050042#ifndef __SC_DELOUSE
Al Viro4f59c712017-07-08 11:40:39 -040043#define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v))
Al Viro46836612012-11-23 09:12:59 -050044#endif
45
Dominik Brodowski7303e302018-04-05 11:53:03 +020046#ifndef COMPAT_SYSCALL_DEFINE0
Heiko Carstens217f4432014-02-26 10:56:20 +010047#define COMPAT_SYSCALL_DEFINE0(name) \
Howard McLauchlanc9a21192018-03-21 18:59:08 -070048 asmlinkage long compat_sys_##name(void); \
49 ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \
Heiko Carstens217f4432014-02-26 10:56:20 +010050 asmlinkage long compat_sys_##name(void)
Dominik Brodowski7303e302018-04-05 11:53:03 +020051#endif /* COMPAT_SYSCALL_DEFINE0 */
Heiko Carstens217f4432014-02-26 10:56:20 +010052
Al Viro46836612012-11-23 09:12:59 -050053#define COMPAT_SYSCALL_DEFINE1(name, ...) \
54 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
55#define COMPAT_SYSCALL_DEFINE2(name, ...) \
56 COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
57#define COMPAT_SYSCALL_DEFINE3(name, ...) \
58 COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
59#define COMPAT_SYSCALL_DEFINE4(name, ...) \
60 COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
61#define COMPAT_SYSCALL_DEFINE5(name, ...) \
62 COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
63#define COMPAT_SYSCALL_DEFINE6(name, ...) \
64 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
65
Dominik Brodowski7303e302018-04-05 11:53:03 +020066#ifndef COMPAT_SYSCALL_DEFINEx
Al Viro46836612012-11-23 09:12:59 -050067#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
Dominik Brodowski3e2052e2018-03-22 14:09:17 +010068 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
Andi Kleen83460ec2013-11-12 15:08:36 -080069 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\
70 __attribute__((alias(__stringify(compat_SyS##name)))); \
Howard McLauchlanc9a21192018-03-21 18:59:08 -070071 ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \
Al Viro07fe6e02013-01-21 15:03:44 -050072 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
Sergei Trofimovichf9597f22013-09-11 14:23:28 -070073 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\
Al Viro07fe6e02013-01-21 15:03:44 -050074 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\
Al Viro46836612012-11-23 09:12:59 -050075 { \
Al Viro07fe6e02013-01-21 15:03:44 -050076 return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \
Al Viro46836612012-11-23 09:12:59 -050077 } \
Al Viro07fe6e02013-01-21 15:03:44 -050078 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__))
Dominik Brodowski7303e302018-04-05 11:53:03 +020079#endif /* COMPAT_SYSCALL_DEFINEx */
Al Viro46836612012-11-23 09:12:59 -050080
Al Viro9b064fc2012-12-14 13:49:35 -050081#ifndef compat_user_stack_pointer
82#define compat_user_stack_pointer() current_user_stack_pointer()
83#endif
Al Viro90268432012-12-14 14:47:53 -050084#ifndef compat_sigaltstack /* we'll need that for MIPS */
85typedef struct compat_sigaltstack {
86 compat_uptr_t ss_sp;
87 int ss_flags;
88 compat_size_t ss_size;
89} compat_stack_t;
90#endif
Al Viro90268432012-12-14 14:47:53 -050091
Linus Torvalds1da177e2005-04-16 15:20:36 -070092#define compat_jiffies_to_clock_t(x) \
93 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
94
Stephen Rothwell202e5972005-09-06 15:16:40 -070095typedef __compat_uid32_t compat_uid_t;
96typedef __compat_gid32_t compat_gid_t;
97
Heiko Carstens932602e2014-03-04 16:07:52 +010098typedef compat_ulong_t compat_aio_context_t;
99
Christoph Hellwig5d0e5282010-03-10 15:21:13 -0800100struct compat_sel_arg_struct;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101struct rusage;
102
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400103struct compat_itimerspec {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 struct compat_timespec it_interval;
105 struct compat_timespec it_value;
106};
107
108struct compat_utimbuf {
109 compat_time_t actime;
110 compat_time_t modtime;
111};
112
113struct compat_itimerval {
114 struct compat_timeval it_interval;
115 struct compat_timeval it_value;
116};
117
Al Viro54ad9c42017-06-07 09:42:37 +0100118struct itimerval;
119int get_compat_itimerval(struct itimerval *, const struct compat_itimerval __user *);
120int put_compat_itimerval(struct compat_itimerval __user *, const struct itimerval *);
121
Linus Torvalds1da177e2005-04-16 15:20:36 -0700122struct compat_tms {
123 compat_clock_t tms_utime;
124 compat_clock_t tms_stime;
125 compat_clock_t tms_cutime;
126 compat_clock_t tms_cstime;
127};
128
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800129struct compat_timex {
130 compat_uint_t modes;
131 compat_long_t offset;
132 compat_long_t freq;
133 compat_long_t maxerror;
134 compat_long_t esterror;
135 compat_int_t status;
136 compat_long_t constant;
137 compat_long_t precision;
138 compat_long_t tolerance;
139 struct compat_timeval time;
140 compat_long_t tick;
141 compat_long_t ppsfreq;
142 compat_long_t jitter;
143 compat_int_t shift;
144 compat_long_t stabil;
145 compat_long_t jitcnt;
146 compat_long_t calcnt;
147 compat_long_t errcnt;
148 compat_long_t stbcnt;
Roman Zippel153b5d02008-05-01 04:34:37 -0700149 compat_int_t tai;
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800150
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400151 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
152 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
153 compat_int_t:32; compat_int_t:32; compat_int_t:32;
Stephen Rothwell88959ea2006-03-26 01:37:27 -0800154};
155
Al Viro3a4d44b2017-06-07 09:42:34 +0100156struct timex;
157int compat_get_timex(struct timex *, const struct compat_timex __user *);
158int compat_put_timex(struct compat_timex __user *, const struct timex *);
159
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160#define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
161
162typedef struct {
163 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
164} compat_sigset_t;
165
Al Viro08d32fe2012-12-25 18:38:15 -0500166struct compat_sigaction {
David Howells2a148692013-03-19 14:00:53 +0000167#ifndef __ARCH_HAS_IRIX_SIGACTION
Al Viro08d32fe2012-12-25 18:38:15 -0500168 compat_uptr_t sa_handler;
169 compat_ulong_t sa_flags;
170#else
David Howells2a148692013-03-19 14:00:53 +0000171 compat_uint_t sa_flags;
Al Viro08d32fe2012-12-25 18:38:15 -0500172 compat_uptr_t sa_handler;
173#endif
174#ifdef __ARCH_HAS_SA_RESTORER
175 compat_uptr_t sa_restorer;
176#endif
177 compat_sigset_t sa_mask __packed;
178};
Al Viro08d32fe2012-12-25 18:38:15 -0500179
Al Virob713da62017-07-09 15:53:17 -0400180typedef union compat_sigval {
181 compat_int_t sival_int;
182 compat_uptr_t sival_ptr;
183} compat_sigval_t;
184
185typedef struct compat_siginfo {
186 int si_signo;
187#ifndef __ARCH_HAS_SWAPPED_SIGINFO
188 int si_errno;
189 int si_code;
190#else
191 int si_code;
192 int si_errno;
193#endif
194
195 union {
196 int _pad[128/sizeof(int) - 3];
197
198 /* kill() */
199 struct {
200 compat_pid_t _pid; /* sender's pid */
201 __compat_uid32_t _uid; /* sender's uid */
202 } _kill;
203
204 /* POSIX.1b timers */
205 struct {
206 compat_timer_t _tid; /* timer id */
207 int _overrun; /* overrun count */
208 compat_sigval_t _sigval; /* same as below */
209 } _timer;
210
211 /* POSIX.1b signals */
212 struct {
213 compat_pid_t _pid; /* sender's pid */
214 __compat_uid32_t _uid; /* sender's uid */
215 compat_sigval_t _sigval;
216 } _rt;
217
218 /* SIGCHLD */
219 struct {
220 compat_pid_t _pid; /* which child */
221 __compat_uid32_t _uid; /* sender's uid */
222 int _status; /* exit code */
223 compat_clock_t _utime;
224 compat_clock_t _stime;
225 } _sigchld;
226
227#ifdef CONFIG_X86_X32_ABI
228 /* SIGCHLD (x32 version) */
229 struct {
230 compat_pid_t _pid; /* which child */
231 __compat_uid32_t _uid; /* sender's uid */
232 int _status; /* exit code */
233 compat_s64 _utime;
234 compat_s64 _stime;
235 } _sigchld_x32;
236#endif
237
238 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
239 struct {
240 compat_uptr_t _addr; /* faulting insn/memory ref. */
241#ifdef __ARCH_SI_TRAPNO
242 int _trapno; /* TRAP # which caused the signal */
243#endif
Al Virob713da62017-07-09 15:53:17 -0400244 union {
Eric W. Biedermanb68a68d2017-07-31 10:08:59 -0500245 /*
246 * used when si_code=BUS_MCEERR_AR or
247 * used when si_code=BUS_MCEERR_AO
248 */
249 short int _addr_lsb; /* Valid LSB of the reported address. */
Al Virob713da62017-07-09 15:53:17 -0400250 /* used when si_code=SEGV_BNDERR */
251 struct {
Eric W. Biederman859d8802018-03-06 00:20:25 -0600252 compat_uptr_t _dummy_bnd;
Al Virob713da62017-07-09 15:53:17 -0400253 compat_uptr_t _lower;
254 compat_uptr_t _upper;
255 } _addr_bnd;
256 /* used when si_code=SEGV_PKUERR */
Eric W. Biedermanb68a68d2017-07-31 10:08:59 -0500257 struct {
Eric W. Biederman859d8802018-03-06 00:20:25 -0600258 compat_uptr_t _dummy_pkey;
Eric W. Biedermanb68a68d2017-07-31 10:08:59 -0500259 u32 _pkey;
260 } _addr_pkey;
Al Virob713da62017-07-09 15:53:17 -0400261 };
262 } _sigfault;
263
264 /* SIGPOLL */
265 struct {
266 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */
267 int _fd;
268 } _sigpoll;
269
270 struct {
271 compat_uptr_t _call_addr; /* calling user insn */
272 int _syscall; /* triggering system call number */
273 unsigned int _arch; /* AUDIT_ARCH_* of syscall */
274 } _sigsys;
275 } _sifields;
276} compat_siginfo_t;
277
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800278/*
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800279 * These functions operate on 32- or 64-bit specs depending on
H. Peter Anvin81993e82014-02-01 18:54:11 -0800280 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments.
H. Peter Anvin6684ba22012-02-19 17:38:00 -0800281 */
282extern int compat_get_timespec(struct timespec *, const void __user *);
283extern int compat_put_timespec(const struct timespec *, void __user *);
284extern int compat_get_timeval(struct timeval *, const void __user *);
285extern int compat_put_timeval(const struct timeval *, void __user *);
Deepa Dinamanif59dd9c2017-06-24 11:45:02 -0700286extern int compat_get_timespec64(struct timespec64 *, const void __user *);
287extern int compat_put_timespec64(const struct timespec64 *, void __user *);
Deepa Dinamanid5b7ffb2017-06-24 11:45:03 -0700288extern int get_compat_itimerspec64(struct itimerspec64 *its,
289 const struct compat_itimerspec __user *uits);
290extern int put_compat_itimerspec64(const struct itimerspec64 *its,
291 struct compat_itimerspec __user *uits);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292
293struct compat_iovec {
294 compat_uptr_t iov_base;
295 compat_size_t iov_len;
296};
297
298struct compat_rlimit {
299 compat_ulong_t rlim_cur;
300 compat_ulong_t rlim_max;
301};
302
303struct compat_rusage {
304 struct compat_timeval ru_utime;
305 struct compat_timeval ru_stime;
306 compat_long_t ru_maxrss;
307 compat_long_t ru_ixrss;
308 compat_long_t ru_idrss;
309 compat_long_t ru_isrss;
310 compat_long_t ru_minflt;
311 compat_long_t ru_majflt;
312 compat_long_t ru_nswap;
313 compat_long_t ru_inblock;
314 compat_long_t ru_oublock;
315 compat_long_t ru_msgsnd;
316 compat_long_t ru_msgrcv;
317 compat_long_t ru_nsignals;
318 compat_long_t ru_nvcsw;
319 compat_long_t ru_nivcsw;
320};
321
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400322extern int put_compat_rusage(const struct rusage *,
323 struct compat_rusage __user *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325struct compat_siginfo;
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327struct compat_dirent {
328 u32 d_ino;
329 compat_off_t d_off;
330 u16 d_reclen;
331 char d_name[256];
332};
333
Christoph Hellwig2b1c6bd2008-11-28 10:09:09 +0100334struct compat_ustat {
335 compat_daddr_t f_tfree;
336 compat_ino_t f_tinode;
337 char f_fname[6];
338 char f_fpack[6];
339};
340
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341#define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
342
343typedef struct compat_sigevent {
344 compat_sigval_t sigev_value;
345 compat_int_t sigev_signo;
346 compat_int_t sigev_notify;
347 union {
348 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
349 compat_int_t _tid;
350
351 struct {
352 compat_uptr_t _function;
353 compat_uptr_t _attribute;
354 } _sigev_thread;
355 } _sigev_un;
356} compat_sigevent_t;
357
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000358struct compat_ifmap {
359 compat_ulong_t mem_start;
360 compat_ulong_t mem_end;
361 unsigned short base_addr;
362 unsigned char irq;
363 unsigned char dma;
364 unsigned char port;
365};
366
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400367struct compat_if_settings {
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800368 unsigned int type; /* Type of physical device or protocol */
369 unsigned int size; /* Size of the data allocated by the caller */
370 compat_uptr_t ifs_ifsu; /* union of pointers */
371};
372
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000373struct compat_ifreq {
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800374 union {
375 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */
376 } ifr_ifrn;
377 union {
378 struct sockaddr ifru_addr;
379 struct sockaddr ifru_dstaddr;
380 struct sockaddr ifru_broadaddr;
381 struct sockaddr ifru_netmask;
382 struct sockaddr ifru_hwaddr;
383 short ifru_flags;
384 compat_int_t ifru_ivalue;
385 compat_int_t ifru_mtu;
386 struct compat_ifmap ifru_map;
387 char ifru_slave[IFNAMSIZ]; /* Just fits the size */
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000388 char ifru_newname[IFNAMSIZ];
Arnd Bergmann7a50a242009-11-08 20:57:03 -0800389 compat_caddr_t ifru_data;
390 struct compat_if_settings ifru_settings;
391 } ifr_ifru;
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000392};
393
394struct compat_ifconf {
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400395 compat_int_t ifc_len; /* size of buffer */
396 compat_caddr_t ifcbuf;
Arnd Bergmann2dceba12009-11-06 08:09:03 +0000397};
398
Ingo Molnar34f192c2006-03-27 01:16:24 -0800399struct compat_robust_list {
400 compat_uptr_t next;
401};
402
403struct compat_robust_list_head {
404 struct compat_robust_list list;
405 compat_long_t futex_offset;
406 compat_uptr_t list_op_pending;
407};
408
Al Viro495dfbf2012-12-25 19:09:45 -0500409#ifdef CONFIG_COMPAT_OLD_SIGACTION
410struct compat_old_sigaction {
411 compat_uptr_t sa_handler;
412 compat_old_sigset_t sa_mask;
413 compat_ulong_t sa_flags;
414 compat_uptr_t sa_restorer;
415};
416#endif
417
Stephan Muellerf1c316a2016-08-19 20:39:09 +0200418struct compat_keyctl_kdf_params {
419 compat_uptr_t hashname;
420 compat_uptr_t otherinfo;
421 __u32 otherinfolen;
422 __u32 __spare[8];
423};
424
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400425struct compat_statfs;
426struct compat_statfs64;
427struct compat_old_linux_dirent;
428struct compat_linux_dirent;
429struct linux_dirent64;
430struct compat_msghdr;
431struct compat_mmsghdr;
432struct compat_sysinfo;
433struct compat_sysctl_args;
434struct compat_kexec_segment;
435struct compat_mq_attr;
Chris Metcalf48b25c42012-03-15 13:13:38 -0400436struct compat_msgbuf;
Chris Metcalfbe84cb42011-05-09 13:12:30 -0400437
Ingo Molnar34f192c2006-03-27 01:16:24 -0800438extern void compat_exit_robust_list(struct task_struct *curr);
439
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
441
Al Viro1e1fc132017-05-30 00:29:38 -0400442#define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Stephen Rothwell5fa38392006-10-28 10:38:46 -0700444long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 unsigned long bitmap_size);
446long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
447 unsigned long bitmap_size);
Eric W. Biederman212a36a2017-07-31 17:15:31 -0500448int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from);
Al Viroce395962013-10-13 17:23:53 -0400449int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450int get_compat_sigevent(struct sigevent *event,
451 const struct compat_sigevent __user *u_event);
452
Andrew Morton643a6542006-02-11 17:55:52 -0800453static inline int compat_timeval_compare(struct compat_timeval *lhs,
454 struct compat_timeval *rhs)
455{
456 if (lhs->tv_sec < rhs->tv_sec)
457 return -1;
458 if (lhs->tv_sec > rhs->tv_sec)
459 return 1;
460 return lhs->tv_usec - rhs->tv_usec;
461}
462
463static inline int compat_timespec_compare(struct compat_timespec *lhs,
464 struct compat_timespec *rhs)
465{
466 if (lhs->tv_sec < rhs->tv_sec)
467 return -1;
468 if (lhs->tv_sec > rhs->tv_sec)
469 return 1;
470 return lhs->tv_nsec - rhs->tv_nsec;
471}
472
Al Viro3968cf62017-09-03 21:45:17 -0400473extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
Matt Redfearnfde9fc72018-02-19 16:55:06 +0000474
475/*
476 * Defined inline such that size can be compile time constant, which avoids
477 * CONFIG_HARDENED_USERCOPY complaining about copies from task_struct
478 */
479static inline int
480put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
481 unsigned int size)
482{
483 /* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */
484#ifdef __BIG_ENDIAN
485 compat_sigset_t v;
486 switch (_NSIG_WORDS) {
487 case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
488 case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
489 case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
490 case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
491 }
492 return copy_to_user(compat, &v, size) ? -EFAULT : 0;
493#else
494 return copy_to_user(compat, set, size) ? -EFAULT : 0;
495#endif
496}
Andi Kleenbebfa102006-06-26 13:56:52 +0200497
Roland McGrath032d82d2008-01-30 13:31:47 +0100498extern int compat_ptrace_request(struct task_struct *child,
499 compat_long_t request,
500 compat_ulong_t addr, compat_ulong_t data);
501
Roland McGrathc269f192008-01-30 13:31:48 +0100502extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
503 compat_ulong_t addr, compat_ulong_t data);
Roland McGrathc269f192008-01-30 13:31:48 +0100504
Al Viro35280bd2013-02-24 14:52:17 -0500505struct epoll_event; /* fortunately, this one is fixed-layout */
Heiko Carstens4c696ba2009-01-14 14:13:53 +0100506
Jeff Moyerb8373362010-05-26 14:44:25 -0700507extern ssize_t compat_rw_copy_check_uvector(int type,
Chris Metcalf4800a5b2011-05-17 14:41:06 -0400508 const struct compat_iovec __user *uvector,
509 unsigned long nr_segs,
Jeff Moyerb8373362010-05-26 14:44:25 -0700510 unsigned long fast_segs, struct iovec *fast_pointer,
Christopher Yeohac34ebb2012-05-31 16:26:42 -0700511 struct iovec **ret_pointer);
H. Peter Anvinc41d68a2010-09-07 16:16:18 -0700512
513extern void __user *compat_alloc_user_space(unsigned long len);
514
Al Viro90268432012-12-14 14:47:53 -0500515int compat_restore_altstack(const compat_stack_t __user *uss);
Al Viroc40702c2012-11-20 14:24:26 -0500516int __compat_save_altstack(compat_stack_t __user *, unsigned long);
Al Virobd1c149a2013-09-01 20:35:01 +0100517#define compat_save_altstack_ex(uss, sp) do { \
518 compat_stack_t __user *__uss = uss; \
519 struct task_struct *t = current; \
520 put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &__uss->ss_sp); \
Stas Sergeev441398d2017-02-27 14:27:25 -0800521 put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \
Al Virobd1c149a2013-09-01 20:35:01 +0100522 put_user_ex(t->sas_ss_size, &__uss->ss_size); \
Stas Sergeev441398d2017-02-27 14:27:25 -0800523 if (t->sas_ss_flags & SS_AUTODISARM) \
524 sas_ss_reset(t); \
Al Virobd1c149a2013-09-01 20:35:01 +0100525} while (0);
Catalin Marinas8f9c0112012-09-19 12:01:52 +0100526
Dominik Brodowskic679a082018-03-25 23:04:48 +0200527/*
528 * These syscall function prototypes are kept in the same order as
Dominik Brodowski3e2052e2018-03-22 14:09:17 +0100529 * include/uapi/asm-generic/unistd.h. Deprecated or obsolete system calls
530 * go below.
Dominik Brodowskic679a082018-03-25 23:04:48 +0200531 *
532 * Please note that these prototypes here are only provided for information
533 * purposes, for static analysis, and for linking from the syscall table.
534 * These functions should not be called elsewhere from kernel code.
Dominik Brodowski7303e302018-04-05 11:53:03 +0200535 *
536 * As the syscall calling convention may be different from the default
537 * for architectures overriding the syscall calling convention, do not
538 * include the prototypes if CONFIG_ARCH_HAS_SYSCALL_WRAPPER is enabled.
Dominik Brodowskic679a082018-03-25 23:04:48 +0200539 */
Dominik Brodowski7303e302018-04-05 11:53:03 +0200540#ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
Dominik Brodowskic679a082018-03-25 23:04:48 +0200541asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
542asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
543 u32 __user *iocb);
544asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id,
545 compat_long_t min_nr,
546 compat_long_t nr,
547 struct io_event __user *events,
548 struct compat_timespec __user *timeout);
549
550/* fs/cookies.c */
551asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
552
553/* fs/eventpoll.c */
554asmlinkage long compat_sys_epoll_pwait(int epfd,
555 struct epoll_event __user *events,
556 int maxevents, int timeout,
557 const compat_sigset_t __user *sigmask,
558 compat_size_t sigsetsize);
559
560/* fs/fcntl.c */
561asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
562 compat_ulong_t arg);
563asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
564 compat_ulong_t arg);
565
566/* fs/ioctl.c */
567asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
568 compat_ulong_t arg);
569
570/* fs/namespace.c */
571asmlinkage long compat_sys_mount(const char __user *dev_name,
572 const char __user *dir_name,
573 const char __user *type, compat_ulong_t flags,
574 const void __user *data);
575
576/* fs/open.c */
577asmlinkage long compat_sys_statfs(const char __user *pathname,
578 struct compat_statfs __user *buf);
579asmlinkage long compat_sys_statfs64(const char __user *pathname,
580 compat_size_t sz,
581 struct compat_statfs64 __user *buf);
582asmlinkage long compat_sys_fstatfs(unsigned int fd,
583 struct compat_statfs __user *buf);
584asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
585 struct compat_statfs64 __user *buf);
586asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
587asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
588/* No generic prototype for truncate64, ftruncate64, fallocate */
589asmlinkage long compat_sys_openat(int dfd, const char __user *filename,
590 int flags, umode_t mode);
591
592/* fs/readdir.c */
593asmlinkage long compat_sys_getdents(unsigned int fd,
594 struct compat_linux_dirent __user *dirent,
595 unsigned int count);
596
597/* fs/read_write.c */
598asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
599asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd,
600 const struct compat_iovec __user *vec, compat_ulong_t vlen);
601asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd,
602 const struct compat_iovec __user *vec, compat_ulong_t vlen);
603/* No generic prototype for pread64 and pwrite64 */
604asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
605 const struct compat_iovec __user *vec,
606 compat_ulong_t vlen, u32 pos_low, u32 pos_high);
607asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
608 const struct compat_iovec __user *vec,
609 compat_ulong_t vlen, u32 pos_low, u32 pos_high);
610#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
611asmlinkage long compat_sys_preadv64(unsigned long fd,
612 const struct compat_iovec __user *vec,
613 unsigned long vlen, loff_t pos);
614#endif
615
616#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
617asmlinkage long compat_sys_pwritev64(unsigned long fd,
618 const struct compat_iovec __user *vec,
619 unsigned long vlen, loff_t pos);
620#endif
621
622/* fs/sendfile.c */
623asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
624 compat_off_t __user *offset, compat_size_t count);
625asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
626 compat_loff_t __user *offset, compat_size_t count);
627
628/* fs/select.c */
629asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
630 compat_ulong_t __user *outp,
631 compat_ulong_t __user *exp,
632 struct compat_timespec __user *tsp,
633 void __user *sig);
634asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
635 unsigned int nfds,
636 struct compat_timespec __user *tsp,
637 const compat_sigset_t __user *sigmask,
638 compat_size_t sigsetsize);
639
640/* fs/signalfd.c */
641asmlinkage long compat_sys_signalfd4(int ufd,
642 const compat_sigset_t __user *sigmask,
643 compat_size_t sigsetsize, int flags);
644
645/* fs/splice.c */
646asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
647 unsigned int nr_segs, unsigned int flags);
648
649/* fs/stat.c */
650asmlinkage long compat_sys_newfstatat(unsigned int dfd,
651 const char __user *filename,
652 struct compat_stat __user *statbuf,
653 int flag);
654asmlinkage long compat_sys_newfstat(unsigned int fd,
655 struct compat_stat __user *statbuf);
656
657/* fs/sync.c: No generic prototype for sync_file_range and sync_file_range2 */
658
659/* fs/timerfd.c */
660asmlinkage long compat_sys_timerfd_gettime(int ufd,
661 struct compat_itimerspec __user *otmr);
662asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
663 const struct compat_itimerspec __user *utmr,
664 struct compat_itimerspec __user *otmr);
665
666/* fs/utimes.c */
667asmlinkage long compat_sys_utimensat(unsigned int dfd,
668 const char __user *filename,
669 struct compat_timespec __user *t,
670 int flags);
671
672/* kernel/exit.c */
673asmlinkage long compat_sys_waitid(int, compat_pid_t,
674 struct compat_siginfo __user *, int,
675 struct compat_rusage __user *);
676
677
678
679/* kernel/futex.c */
680asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
681 struct compat_timespec __user *utime, u32 __user *uaddr2,
682 u32 val3);
683asmlinkage long
684compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
685 compat_size_t len);
686asmlinkage long
687compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
688 compat_size_t __user *len_ptr);
689
690/* kernel/hrtimer.c */
691asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
692 struct compat_timespec __user *rmtp);
693
694/* kernel/itimer.c */
695asmlinkage long compat_sys_getitimer(int which,
696 struct compat_itimerval __user *it);
697asmlinkage long compat_sys_setitimer(int which,
698 struct compat_itimerval __user *in,
699 struct compat_itimerval __user *out);
700
701/* kernel/kexec.c */
702asmlinkage long compat_sys_kexec_load(compat_ulong_t entry,
703 compat_ulong_t nr_segments,
704 struct compat_kexec_segment __user *,
705 compat_ulong_t flags);
706
707/* kernel/posix-timers.c */
708asmlinkage long compat_sys_timer_create(clockid_t which_clock,
709 struct compat_sigevent __user *timer_event_spec,
710 timer_t __user *created_timer_id);
711asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
712 struct compat_itimerspec __user *setting);
713asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
714 struct compat_itimerspec __user *new,
715 struct compat_itimerspec __user *old);
716asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
717 struct compat_timespec __user *tp);
718asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
719 struct compat_timespec __user *tp);
720asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
721 struct compat_timespec __user *tp);
722asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
723 struct compat_timespec __user *rqtp,
724 struct compat_timespec __user *rmtp);
725
726/* kernel/ptrace.c */
727asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
728 compat_long_t addr, compat_long_t data);
729
730/* kernel/sched/core.c */
731asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
732 unsigned int len,
733 compat_ulong_t __user *user_mask_ptr);
734asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
735 unsigned int len,
736 compat_ulong_t __user *user_mask_ptr);
Catalin Marinas0ad50c32012-12-17 16:01:45 -0800737asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
738 struct compat_timespec __user *interval);
739
Dominik Brodowskic679a082018-03-25 23:04:48 +0200740/* kernel/signal.c */
741asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
742 compat_stack_t __user *uoss_ptr);
743asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
744 compat_size_t sigsetsize);
745#ifndef CONFIG_ODD_RT_SIGACTION
746asmlinkage long compat_sys_rt_sigaction(int,
747 const struct compat_sigaction __user *,
748 struct compat_sigaction __user *,
749 compat_size_t);
750#endif
751asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set,
752 compat_sigset_t __user *oset,
753 compat_size_t sigsetsize);
754asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
755 compat_size_t sigsetsize);
756asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
757 struct compat_siginfo __user *uinfo,
758 struct compat_timespec __user *uts, compat_size_t sigsetsize);
759asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
760 struct compat_siginfo __user *uinfo);
761/* No generic prototype for rt_sigreturn */
762
763/* kernel/sys.c */
764asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
765asmlinkage long compat_sys_getrlimit(unsigned int resource,
766 struct compat_rlimit __user *rlim);
767asmlinkage long compat_sys_setrlimit(unsigned int resource,
768 struct compat_rlimit __user *rlim);
769asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
770
771/* kernel/time.c */
772asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
773 struct timezone __user *tz);
774asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
775 struct timezone __user *tz);
776asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
777
778/* kernel/timer.c */
779asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
780
781/* ipc/mqueue.c */
782asmlinkage long compat_sys_mq_open(const char __user *u_name,
783 int oflag, compat_mode_t mode,
784 struct compat_mq_attr __user *u_attr);
785asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
786 const char __user *u_msg_ptr,
787 compat_size_t msg_len, unsigned int msg_prio,
788 const struct compat_timespec __user *u_abs_timeout);
789asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
790 char __user *u_msg_ptr,
791 compat_size_t msg_len, unsigned int __user *u_msg_prio,
792 const struct compat_timespec __user *u_abs_timeout);
793asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
794 const struct compat_sigevent __user *u_notification);
795asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
796 const struct compat_mq_attr __user *u_mqstat,
797 struct compat_mq_attr __user *u_omqstat);
798
799/* ipc/msg.c */
800asmlinkage long compat_sys_msgctl(int first, int second, void __user *uptr);
801asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
802 compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg);
803asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
804 compat_ssize_t msgsz, int msgflg);
805
806/* ipc/sem.c */
807asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
808asmlinkage long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
809 unsigned nsems, const struct compat_timespec __user *timeout);
810
811/* ipc/shm.c */
812asmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr);
813asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
814
815/* net/socket.c */
816asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len,
817 unsigned flags, struct sockaddr __user *addr,
818 int __user *addrlen);
819asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
820 char __user *optval, unsigned int optlen);
821asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
822 char __user *optval, int __user *optlen);
823asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
824 unsigned flags);
825asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
826 unsigned int flags);
827
828/* mm/filemap.c: No generic prototype for readahead */
829
830/* security/keys/keyctl.c */
831asmlinkage long compat_sys_keyctl(u32 option,
832 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
833
834/* arch/example/kernel/sys_example.c */
835asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
836 const compat_uptr_t __user *envp);
837
838/* mm/fadvise.c: No generic prototype for fadvise64_64 */
839
840/* mm/, CONFIG_MMU only */
841asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
842 compat_ulong_t mode,
843 compat_ulong_t __user *nmask,
844 compat_ulong_t maxnode, compat_ulong_t flags);
845asmlinkage long compat_sys_get_mempolicy(int __user *policy,
846 compat_ulong_t __user *nmask,
847 compat_ulong_t maxnode,
848 compat_ulong_t addr,
849 compat_ulong_t flags);
850asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
851 compat_ulong_t maxnode);
852asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
853 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
854 const compat_ulong_t __user *new_nodes);
855asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages,
856 __u32 __user *pages,
857 const int __user *nodes,
858 int __user *status,
859 int flags);
860
861asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid,
862 compat_pid_t pid, int sig,
863 struct compat_siginfo __user *uinfo);
864asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
865 unsigned vlen, unsigned int flags,
866 struct compat_timespec __user *timeout);
867asmlinkage long compat_sys_wait4(compat_pid_t pid,
868 compat_uint_t __user *stat_addr, int options,
869 struct compat_rusage __user *ru);
Al Viro91c2e0b2013-03-05 20:10:59 -0500870asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
871 int, const char __user *);
Dominik Brodowskic679a082018-03-25 23:04:48 +0200872asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
873 struct file_handle __user *handle,
874 int flags);
875asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
876 struct compat_timex __user *tp);
877asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
878 unsigned vlen, unsigned int flags);
879asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid,
880 const struct compat_iovec __user *lvec,
881 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
882 compat_ulong_t riovcnt, compat_ulong_t flags);
883asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid,
884 const struct compat_iovec __user *lvec,
885 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec,
886 compat_ulong_t riovcnt, compat_ulong_t flags);
887asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
888 const compat_uptr_t __user *argv,
889 const compat_uptr_t __user *envp, int flags);
890asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd,
891 const struct compat_iovec __user *vec,
892 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
893asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
894 const struct compat_iovec __user *vec,
895 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
896#ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2
897asmlinkage long compat_sys_readv64v2(unsigned long fd,
898 const struct compat_iovec __user *vec,
899 unsigned long vlen, loff_t pos, rwf_t flags);
900#endif
Andy Lutomirski5180e3e2016-03-22 14:24:43 -0700901
Dominik Brodowskic679a082018-03-25 23:04:48 +0200902#ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2
903asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
904 const struct compat_iovec __user *vec,
905 unsigned long vlen, loff_t pos, rwf_t flags);
906#endif
907
908
909/*
Dominik Brodowskic679a082018-03-25 23:04:48 +0200910 * Deprecated system calls which are still defined in
911 * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch
912 */
913
914/* __ARCH_WANT_SYSCALL_NO_AT */
915asmlinkage long compat_sys_open(const char __user *filename, int flags,
916 umode_t mode);
917asmlinkage long compat_sys_utimes(const char __user *filename,
918 struct compat_timeval __user *t);
919
920/* __ARCH_WANT_SYSCALL_NO_FLAGS */
921asmlinkage long compat_sys_signalfd(int ufd,
922 const compat_sigset_t __user *sigmask,
923 compat_size_t sigsetsize);
924
925/* __ARCH_WANT_SYSCALL_OFF_T */
926asmlinkage long compat_sys_newstat(const char __user *filename,
927 struct compat_stat __user *statbuf);
928asmlinkage long compat_sys_newlstat(const char __user *filename,
929 struct compat_stat __user *statbuf);
930
931/* __ARCH_WANT_SYSCALL_DEPRECATED */
932asmlinkage long compat_sys_time(compat_time_t __user *tloc);
933asmlinkage long compat_sys_utime(const char __user *filename,
934 struct compat_utimbuf __user *t);
935asmlinkage long compat_sys_futimesat(unsigned int dfd,
936 const char __user *filename,
937 struct compat_timeval __user *t);
938asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
939 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
940 struct compat_timeval __user *tvp);
941asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
942asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
943 unsigned flags);
944asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
945
946/* obsolete: fs/readdir.c */
947asmlinkage long compat_sys_old_readdir(unsigned int fd,
948 struct compat_old_linux_dirent __user *,
949 unsigned int count);
950
951/* obsolete: fs/select.c */
952asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
953
954/* obsolete: ipc */
955asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
956
957/* obsolete: kernel/signal.c */
958#ifdef __ARCH_WANT_SYS_SIGPENDING
959asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set);
960#endif
961
962#ifdef __ARCH_WANT_SYS_SIGPROCMASK
963asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset,
964 compat_old_sigset_t __user *oset);
965#endif
966#ifdef CONFIG_COMPAT_OLD_SIGACTION
967asmlinkage long compat_sys_sigaction(int sig,
968 const struct compat_old_sigaction __user *act,
969 struct compat_old_sigaction __user *oact);
970#endif
971
972/* obsolete: kernel/time/time.c */
973asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
974
975/* obsolete: net/socket.c */
976asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
977
Dominik Brodowski7303e302018-04-05 11:53:03 +0200978#endif /* CONFIG_ARCH_HAS_SYSCALL_WRAPPER */
979
Dominik Brodowskic679a082018-03-25 23:04:48 +0200980
Andy Lutomirski5180e3e2016-03-22 14:24:43 -0700981/*
982 * For most but not all architectures, "am I in a compat syscall?" and
983 * "am I a compat task?" are the same question. For architectures on which
984 * they aren't the same question, arch code can override in_compat_syscall.
985 */
986
987#ifndef in_compat_syscall
988static inline bool in_compat_syscall(void) { return is_compat_task(); }
989#endif
990
Frederic Weisbeckercd19c362017-01-31 04:09:27 +0100991/**
992 * ns_to_compat_timeval - Compat version of ns_to_timeval
993 * @nsec: the nanoseconds value to be converted
994 *
995 * Returns the compat_timeval representation of the nsec parameter.
996 */
997static inline struct compat_timeval ns_to_compat_timeval(s64 nsec)
998{
999 struct timeval tv;
1000 struct compat_timeval ctv;
1001
1002 tv = ns_to_timeval(nsec);
1003 ctv.tv_sec = tv.tv_sec;
1004 ctv.tv_usec = tv.tv_usec;
1005
1006 return ctv;
1007}
1008
1009#else /* !CONFIG_COMPAT */
Linus Torvalds3c761ea2012-02-26 09:44:55 -08001010
1011#define is_compat_task() (0)
Andy Lutomirski5180e3e2016-03-22 14:24:43 -07001012static inline bool in_compat_syscall(void) { return false; }
Linus Torvalds3c761ea2012-02-26 09:44:55 -08001013
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014#endif /* CONFIG_COMPAT */
Andy Lutomirski5180e3e2016-03-22 14:24:43 -07001015
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016#endif /* _LINUX_COMPAT_H */