xref: /linux-6.15/include/linux/compat.h (revision 4800a5bb)
11da177e4SLinus Torvalds #ifndef _LINUX_COMPAT_H
21da177e4SLinus Torvalds #define _LINUX_COMPAT_H
31da177e4SLinus Torvalds /*
41da177e4SLinus Torvalds  * These are the type definitions for the architecture specific
51da177e4SLinus Torvalds  * syscall compatibility layer.
61da177e4SLinus Torvalds  */
71da177e4SLinus Torvalds 
81da177e4SLinus Torvalds #ifdef CONFIG_COMPAT
91da177e4SLinus Torvalds 
101da177e4SLinus Torvalds #include <linux/stat.h>
111da177e4SLinus Torvalds #include <linux/param.h>	/* for HZ */
121da177e4SLinus Torvalds #include <linux/sem.h>
132dceba14SArnd Bergmann #include <linux/socket.h>
142dceba14SArnd Bergmann #include <linux/if.h>
15be84cb43SChris Metcalf #include <linux/fs.h>
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds #include <asm/compat.h>
181da177e4SLinus Torvalds #include <asm/siginfo.h>
193f2e05e9SDavid Howells #include <asm/signal.h>
201da177e4SLinus Torvalds 
211da177e4SLinus Torvalds #define compat_jiffies_to_clock_t(x)	\
221da177e4SLinus Torvalds 		(((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
231da177e4SLinus Torvalds 
24202e5979SStephen Rothwell typedef __compat_uid32_t	compat_uid_t;
25202e5979SStephen Rothwell typedef __compat_gid32_t	compat_gid_t;
26202e5979SStephen Rothwell 
275d0e5283SChristoph Hellwig struct compat_sel_arg_struct;
281da177e4SLinus Torvalds struct rusage;
291da177e4SLinus Torvalds 
301da177e4SLinus Torvalds struct compat_itimerspec {
311da177e4SLinus Torvalds 	struct compat_timespec it_interval;
321da177e4SLinus Torvalds 	struct compat_timespec it_value;
331da177e4SLinus Torvalds };
341da177e4SLinus Torvalds 
351da177e4SLinus Torvalds struct compat_utimbuf {
361da177e4SLinus Torvalds 	compat_time_t		actime;
371da177e4SLinus Torvalds 	compat_time_t		modtime;
381da177e4SLinus Torvalds };
391da177e4SLinus Torvalds 
401da177e4SLinus Torvalds struct compat_itimerval {
411da177e4SLinus Torvalds 	struct compat_timeval	it_interval;
421da177e4SLinus Torvalds 	struct compat_timeval	it_value;
431da177e4SLinus Torvalds };
441da177e4SLinus Torvalds 
451da177e4SLinus Torvalds struct compat_tms {
461da177e4SLinus Torvalds 	compat_clock_t		tms_utime;
471da177e4SLinus Torvalds 	compat_clock_t		tms_stime;
481da177e4SLinus Torvalds 	compat_clock_t		tms_cutime;
491da177e4SLinus Torvalds 	compat_clock_t		tms_cstime;
501da177e4SLinus Torvalds };
511da177e4SLinus Torvalds 
5288959ea9SStephen Rothwell struct compat_timex {
5388959ea9SStephen Rothwell 	compat_uint_t modes;
5488959ea9SStephen Rothwell 	compat_long_t offset;
5588959ea9SStephen Rothwell 	compat_long_t freq;
5688959ea9SStephen Rothwell 	compat_long_t maxerror;
5788959ea9SStephen Rothwell 	compat_long_t esterror;
5888959ea9SStephen Rothwell 	compat_int_t status;
5988959ea9SStephen Rothwell 	compat_long_t constant;
6088959ea9SStephen Rothwell 	compat_long_t precision;
6188959ea9SStephen Rothwell 	compat_long_t tolerance;
6288959ea9SStephen Rothwell 	struct compat_timeval time;
6388959ea9SStephen Rothwell 	compat_long_t tick;
6488959ea9SStephen Rothwell 	compat_long_t ppsfreq;
6588959ea9SStephen Rothwell 	compat_long_t jitter;
6688959ea9SStephen Rothwell 	compat_int_t shift;
6788959ea9SStephen Rothwell 	compat_long_t stabil;
6888959ea9SStephen Rothwell 	compat_long_t jitcnt;
6988959ea9SStephen Rothwell 	compat_long_t calcnt;
7088959ea9SStephen Rothwell 	compat_long_t errcnt;
7188959ea9SStephen Rothwell 	compat_long_t stbcnt;
72153b5d05SRoman Zippel 	compat_int_t tai;
7388959ea9SStephen Rothwell 
7488959ea9SStephen Rothwell 	compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
7588959ea9SStephen Rothwell 	compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32;
76153b5d05SRoman Zippel 	compat_int_t:32; compat_int_t:32; compat_int_t:32;
7788959ea9SStephen Rothwell };
7888959ea9SStephen Rothwell 
791da177e4SLinus Torvalds #define _COMPAT_NSIG_WORDS	(_COMPAT_NSIG / _COMPAT_NSIG_BPW)
801da177e4SLinus Torvalds 
811da177e4SLinus Torvalds typedef struct {
821da177e4SLinus Torvalds 	compat_sigset_word	sig[_COMPAT_NSIG_WORDS];
831da177e4SLinus Torvalds } compat_sigset_t;
841da177e4SLinus Torvalds 
85*4800a5bbSChris Metcalf extern int get_compat_timespec(struct timespec *,
86*4800a5bbSChris Metcalf 			       const struct compat_timespec __user *);
87*4800a5bbSChris Metcalf extern int put_compat_timespec(const struct timespec *,
88*4800a5bbSChris Metcalf 			       struct compat_timespec __user *);
891da177e4SLinus Torvalds 
901da177e4SLinus Torvalds struct compat_iovec {
911da177e4SLinus Torvalds 	compat_uptr_t	iov_base;
921da177e4SLinus Torvalds 	compat_size_t	iov_len;
931da177e4SLinus Torvalds };
941da177e4SLinus Torvalds 
951da177e4SLinus Torvalds struct compat_rlimit {
961da177e4SLinus Torvalds 	compat_ulong_t	rlim_cur;
971da177e4SLinus Torvalds 	compat_ulong_t	rlim_max;
981da177e4SLinus Torvalds };
991da177e4SLinus Torvalds 
1001da177e4SLinus Torvalds struct compat_rusage {
1011da177e4SLinus Torvalds 	struct compat_timeval ru_utime;
1021da177e4SLinus Torvalds 	struct compat_timeval ru_stime;
1031da177e4SLinus Torvalds 	compat_long_t	ru_maxrss;
1041da177e4SLinus Torvalds 	compat_long_t	ru_ixrss;
1051da177e4SLinus Torvalds 	compat_long_t	ru_idrss;
1061da177e4SLinus Torvalds 	compat_long_t	ru_isrss;
1071da177e4SLinus Torvalds 	compat_long_t	ru_minflt;
1081da177e4SLinus Torvalds 	compat_long_t	ru_majflt;
1091da177e4SLinus Torvalds 	compat_long_t	ru_nswap;
1101da177e4SLinus Torvalds 	compat_long_t	ru_inblock;
1111da177e4SLinus Torvalds 	compat_long_t	ru_oublock;
1121da177e4SLinus Torvalds 	compat_long_t	ru_msgsnd;
1131da177e4SLinus Torvalds 	compat_long_t	ru_msgrcv;
1141da177e4SLinus Torvalds 	compat_long_t	ru_nsignals;
1151da177e4SLinus Torvalds 	compat_long_t	ru_nvcsw;
1161da177e4SLinus Torvalds 	compat_long_t	ru_nivcsw;
1171da177e4SLinus Torvalds };
1181da177e4SLinus Torvalds 
119*4800a5bbSChris Metcalf extern int put_compat_rusage(const struct rusage *,
120*4800a5bbSChris Metcalf 			     struct compat_rusage __user *);
1211da177e4SLinus Torvalds 
1221da177e4SLinus Torvalds struct compat_siginfo;
1231da177e4SLinus Torvalds 
1241da177e4SLinus Torvalds extern asmlinkage long compat_sys_waitid(int, compat_pid_t,
1251da177e4SLinus Torvalds 		struct compat_siginfo __user *, int,
1261da177e4SLinus Torvalds 		struct compat_rusage __user *);
1271da177e4SLinus Torvalds 
1281da177e4SLinus Torvalds struct compat_dirent {
1291da177e4SLinus Torvalds 	u32		d_ino;
1301da177e4SLinus Torvalds 	compat_off_t	d_off;
1311da177e4SLinus Torvalds 	u16		d_reclen;
1321da177e4SLinus Torvalds 	char		d_name[256];
1331da177e4SLinus Torvalds };
1341da177e4SLinus Torvalds 
1352b1c6bd7SChristoph Hellwig struct compat_ustat {
1362b1c6bd7SChristoph Hellwig 	compat_daddr_t		f_tfree;
1372b1c6bd7SChristoph Hellwig 	compat_ino_t		f_tinode;
1382b1c6bd7SChristoph Hellwig 	char			f_fname[6];
1392b1c6bd7SChristoph Hellwig 	char			f_fpack[6];
1402b1c6bd7SChristoph Hellwig };
1412b1c6bd7SChristoph Hellwig 
1421da177e4SLinus Torvalds typedef union compat_sigval {
1431da177e4SLinus Torvalds 	compat_int_t	sival_int;
1441da177e4SLinus Torvalds 	compat_uptr_t	sival_ptr;
1451da177e4SLinus Torvalds } compat_sigval_t;
1461da177e4SLinus Torvalds 
1471da177e4SLinus Torvalds #define COMPAT_SIGEV_PAD_SIZE	((SIGEV_MAX_SIZE/sizeof(int)) - 3)
1481da177e4SLinus Torvalds 
1491da177e4SLinus Torvalds typedef struct compat_sigevent {
1501da177e4SLinus Torvalds 	compat_sigval_t sigev_value;
1511da177e4SLinus Torvalds 	compat_int_t sigev_signo;
1521da177e4SLinus Torvalds 	compat_int_t sigev_notify;
1531da177e4SLinus Torvalds 	union {
1541da177e4SLinus Torvalds 		compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
1551da177e4SLinus Torvalds 		compat_int_t _tid;
1561da177e4SLinus Torvalds 
1571da177e4SLinus Torvalds 		struct {
1581da177e4SLinus Torvalds 			compat_uptr_t _function;
1591da177e4SLinus Torvalds 			compat_uptr_t _attribute;
1601da177e4SLinus Torvalds 		} _sigev_thread;
1611da177e4SLinus Torvalds 	} _sigev_un;
1621da177e4SLinus Torvalds } compat_sigevent_t;
1631da177e4SLinus Torvalds 
1642dceba14SArnd Bergmann struct compat_ifmap {
1652dceba14SArnd Bergmann 	compat_ulong_t mem_start;
1662dceba14SArnd Bergmann 	compat_ulong_t mem_end;
1672dceba14SArnd Bergmann 	unsigned short base_addr;
1682dceba14SArnd Bergmann 	unsigned char irq;
1692dceba14SArnd Bergmann 	unsigned char dma;
1702dceba14SArnd Bergmann 	unsigned char port;
1712dceba14SArnd Bergmann };
1722dceba14SArnd Bergmann 
173*4800a5bbSChris Metcalf struct compat_if_settings {
1747a50a240SArnd Bergmann 	unsigned int type;	/* Type of physical device or protocol */
1757a50a240SArnd Bergmann 	unsigned int size;	/* Size of the data allocated by the caller */
1767a50a240SArnd Bergmann 	compat_uptr_t ifs_ifsu;	/* union of pointers */
1777a50a240SArnd Bergmann };
1787a50a240SArnd Bergmann 
1792dceba14SArnd Bergmann struct compat_ifreq {
1802dceba14SArnd Bergmann 	union {
1812dceba14SArnd Bergmann 		char	ifrn_name[IFNAMSIZ];    /* if name, e.g. "en0" */
1822dceba14SArnd Bergmann 	} ifr_ifrn;
1832dceba14SArnd Bergmann 	union {
1842dceba14SArnd Bergmann 		struct	sockaddr ifru_addr;
1852dceba14SArnd Bergmann 		struct	sockaddr ifru_dstaddr;
1862dceba14SArnd Bergmann 		struct	sockaddr ifru_broadaddr;
1872dceba14SArnd Bergmann 		struct	sockaddr ifru_netmask;
1882dceba14SArnd Bergmann 		struct	sockaddr ifru_hwaddr;
1892dceba14SArnd Bergmann 		short	ifru_flags;
1902dceba14SArnd Bergmann 		compat_int_t	ifru_ivalue;
1912dceba14SArnd Bergmann 		compat_int_t	ifru_mtu;
1922dceba14SArnd Bergmann 		struct	compat_ifmap ifru_map;
1932dceba14SArnd Bergmann 		char	ifru_slave[IFNAMSIZ];   /* Just fits the size */
1942dceba14SArnd Bergmann 		char	ifru_newname[IFNAMSIZ];
1952dceba14SArnd Bergmann 		compat_caddr_t	ifru_data;
1967a50a240SArnd Bergmann 		struct	compat_if_settings ifru_settings;
1972dceba14SArnd Bergmann 	} ifr_ifru;
1982dceba14SArnd Bergmann };
1992dceba14SArnd Bergmann 
2002dceba14SArnd Bergmann struct compat_ifconf {
2012dceba14SArnd Bergmann 	compat_int_t	ifc_len;                /* size of buffer */
2022dceba14SArnd Bergmann 	compat_caddr_t  ifcbuf;
2032dceba14SArnd Bergmann };
2042dceba14SArnd Bergmann 
20534f192c6SIngo Molnar struct compat_robust_list {
20634f192c6SIngo Molnar 	compat_uptr_t			next;
20734f192c6SIngo Molnar };
20834f192c6SIngo Molnar 
20934f192c6SIngo Molnar struct compat_robust_list_head {
21034f192c6SIngo Molnar 	struct compat_robust_list	list;
21134f192c6SIngo Molnar 	compat_long_t			futex_offset;
21234f192c6SIngo Molnar 	compat_uptr_t			list_op_pending;
21334f192c6SIngo Molnar };
21434f192c6SIngo Molnar 
215be84cb43SChris Metcalf struct compat_statfs;
216be84cb43SChris Metcalf struct compat_statfs64;
217be84cb43SChris Metcalf struct compat_old_linux_dirent;
218be84cb43SChris Metcalf struct compat_linux_dirent;
219be84cb43SChris Metcalf struct linux_dirent64;
220be84cb43SChris Metcalf struct compat_msghdr;
221be84cb43SChris Metcalf struct compat_mmsghdr;
222be84cb43SChris Metcalf struct compat_sysinfo;
223be84cb43SChris Metcalf struct compat_sysctl_args;
224be84cb43SChris Metcalf struct compat_kexec_segment;
225be84cb43SChris Metcalf struct compat_mq_attr;
226be84cb43SChris Metcalf 
22734f192c6SIngo Molnar extern void compat_exit_robust_list(struct task_struct *curr);
22834f192c6SIngo Molnar 
22934f192c6SIngo Molnar asmlinkage long
23034f192c6SIngo Molnar compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
23134f192c6SIngo Molnar 			   compat_size_t len);
23234f192c6SIngo Molnar asmlinkage long
233ba46df98SAl Viro compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
23434f192c6SIngo Molnar 			   compat_size_t __user *len_ptr);
2351da177e4SLinus Torvalds 
2361da177e4SLinus Torvalds long compat_sys_semctl(int first, int second, int third, void __user *uptr);
2371da177e4SLinus Torvalds long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
2381da177e4SLinus Torvalds long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
2391da177e4SLinus Torvalds 		int version, void __user *uptr);
2401da177e4SLinus Torvalds long compat_sys_msgctl(int first, int second, void __user *uptr);
2411da177e4SLinus Torvalds long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
2421da177e4SLinus Torvalds 		void __user *uptr);
2431da177e4SLinus Torvalds long compat_sys_shmctl(int first, int second, void __user *uptr);
2441da177e4SLinus Torvalds long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
2451da177e4SLinus Torvalds 		unsigned nsems, const struct compat_timespec __user *timeout);
2461da177e4SLinus Torvalds asmlinkage long compat_sys_keyctl(u32 option,
2471da177e4SLinus Torvalds 			      u32 arg2, u32 arg3, u32 arg4, u32 arg5);
2482b1c6bd7SChristoph Hellwig asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
2491da177e4SLinus Torvalds 
2501da177e4SLinus Torvalds asmlinkage ssize_t compat_sys_readv(unsigned long fd,
2511da177e4SLinus Torvalds 		const struct compat_iovec __user *vec, unsigned long vlen);
2521da177e4SLinus Torvalds asmlinkage ssize_t compat_sys_writev(unsigned long fd,
2531da177e4SLinus Torvalds 		const struct compat_iovec __user *vec, unsigned long vlen);
254f3554f4bSGerd Hoffmann asmlinkage ssize_t compat_sys_preadv(unsigned long fd,
255f3554f4bSGerd Hoffmann 		const struct compat_iovec __user *vec,
256601cc11dSLinus Torvalds 		unsigned long vlen, u32 pos_low, u32 pos_high);
257f3554f4bSGerd Hoffmann asmlinkage ssize_t compat_sys_pwritev(unsigned long fd,
258f3554f4bSGerd Hoffmann 		const struct compat_iovec __user *vec,
259601cc11dSLinus Torvalds 		unsigned long vlen, u32 pos_low, u32 pos_high);
2601da177e4SLinus Torvalds 
2611da177e4SLinus Torvalds int compat_do_execve(char *filename, compat_uptr_t __user *argv,
2621da177e4SLinus Torvalds 		     compat_uptr_t __user *envp, struct pt_regs *regs);
2631da177e4SLinus Torvalds 
2641da177e4SLinus Torvalds asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
2651da177e4SLinus Torvalds 		compat_ulong_t __user *outp, compat_ulong_t __user *exp,
2661da177e4SLinus Torvalds 		struct compat_timeval __user *tvp);
2671da177e4SLinus Torvalds 
2685d0e5283SChristoph Hellwig asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
2695d0e5283SChristoph Hellwig 
270c202f298SThomas Gleixner asmlinkage long compat_sys_wait4(compat_pid_t pid,
2717d61c459SAl Viro 				 compat_uint_t __user *stat_addr, int options,
2727d61c459SAl Viro 				 struct compat_rusage __user *ru);
273c202f298SThomas Gleixner 
2741da177e4SLinus Torvalds #define BITS_PER_COMPAT_LONG    (8*sizeof(compat_long_t))
2751da177e4SLinus Torvalds 
2761da177e4SLinus Torvalds #define BITS_TO_COMPAT_LONGS(bits) \
2771da177e4SLinus Torvalds 	(((bits)+BITS_PER_COMPAT_LONG-1)/BITS_PER_COMPAT_LONG)
2781da177e4SLinus Torvalds 
2795fa3839aSStephen Rothwell long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
2801da177e4SLinus Torvalds 		       unsigned long bitmap_size);
2811da177e4SLinus Torvalds long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
2821da177e4SLinus Torvalds 		       unsigned long bitmap_size);
2831da177e4SLinus Torvalds int copy_siginfo_from_user32(siginfo_t *to, struct compat_siginfo __user *from);
2841da177e4SLinus Torvalds int copy_siginfo_to_user32(struct compat_siginfo __user *to, siginfo_t *from);
2851da177e4SLinus Torvalds int get_compat_sigevent(struct sigevent *event,
2861da177e4SLinus Torvalds 		const struct compat_sigevent __user *u_event);
28762ab4505SThomas Gleixner long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig,
28862ab4505SThomas Gleixner 				  struct compat_siginfo __user *uinfo);
2891da177e4SLinus Torvalds 
290643a6545SAndrew Morton static inline int compat_timeval_compare(struct compat_timeval *lhs,
291643a6545SAndrew Morton 					struct compat_timeval *rhs)
292643a6545SAndrew Morton {
293643a6545SAndrew Morton 	if (lhs->tv_sec < rhs->tv_sec)
294643a6545SAndrew Morton 		return -1;
295643a6545SAndrew Morton 	if (lhs->tv_sec > rhs->tv_sec)
296643a6545SAndrew Morton 		return 1;
297643a6545SAndrew Morton 	return lhs->tv_usec - rhs->tv_usec;
298643a6545SAndrew Morton }
299643a6545SAndrew Morton 
300643a6545SAndrew Morton static inline int compat_timespec_compare(struct compat_timespec *lhs,
301643a6545SAndrew Morton 					struct compat_timespec *rhs)
302643a6545SAndrew Morton {
303643a6545SAndrew Morton 	if (lhs->tv_sec < rhs->tv_sec)
304643a6545SAndrew Morton 		return -1;
305643a6545SAndrew Morton 	if (lhs->tv_sec > rhs->tv_sec)
306643a6545SAndrew Morton 		return 1;
307643a6545SAndrew Morton 	return lhs->tv_nsec - rhs->tv_nsec;
308643a6545SAndrew Morton }
309643a6545SAndrew Morton 
31083f5d126SDavide Libenzi extern int get_compat_itimerspec(struct itimerspec *dst,
31183f5d126SDavide Libenzi 				 const struct compat_itimerspec __user *src);
31283f5d126SDavide Libenzi extern int put_compat_itimerspec(struct compat_itimerspec __user *dst,
31383f5d126SDavide Libenzi 				 const struct itimerspec *src);
31483f5d126SDavide Libenzi 
315b418da16SChristoph Hellwig asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv,
316b418da16SChristoph Hellwig 		struct timezone __user *tz);
317b418da16SChristoph Hellwig asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv,
318b418da16SChristoph Hellwig 		struct timezone __user *tz);
319b418da16SChristoph Hellwig 
3203158e941SStephen Rothwell asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp);
3213158e941SStephen Rothwell 
322bebfa101SAndi Kleen extern int compat_printk(const char *fmt, ...);
3230235497fSLinus Torvalds extern void sigset_from_compat(sigset_t *set, compat_sigset_t *compat);
324bebfa101SAndi Kleen 
3253fd59397SStephen Rothwell asmlinkage long compat_sys_migrate_pages(compat_pid_t pid,
3263fd59397SStephen Rothwell 		compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes,
3273fd59397SStephen Rothwell 		const compat_ulong_t __user *new_nodes);
3283fd59397SStephen Rothwell 
329032d82d9SRoland McGrath extern int compat_ptrace_request(struct task_struct *child,
330032d82d9SRoland McGrath 				 compat_long_t request,
331032d82d9SRoland McGrath 				 compat_ulong_t addr, compat_ulong_t data);
332032d82d9SRoland McGrath 
333c269f196SRoland McGrath extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
334c269f196SRoland McGrath 			       compat_ulong_t addr, compat_ulong_t data);
335c269f196SRoland McGrath asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
336c269f196SRoland McGrath 				  compat_long_t addr, compat_long_t data);
337c269f196SRoland McGrath 
338f6dfb4fdSDavide Libenzi /*
339f6dfb4fdSDavide Libenzi  * epoll (fs/eventpoll.c) compat bits follow ...
340f6dfb4fdSDavide Libenzi  */
341f6dfb4fdSDavide Libenzi struct epoll_event;
342f6dfb4fdSDavide Libenzi #define compat_epoll_event	epoll_event
343f6dfb4fdSDavide Libenzi asmlinkage long compat_sys_epoll_pwait(int epfd,
344f6dfb4fdSDavide Libenzi 			struct compat_epoll_event __user *events,
345f6dfb4fdSDavide Libenzi 			int maxevents, int timeout,
346f6dfb4fdSDavide Libenzi 			const compat_sigset_t __user *sigmask,
347f6dfb4fdSDavide Libenzi 			compat_size_t sigsetsize);
348f6dfb4fdSDavide Libenzi 
349be84cb43SChris Metcalf asmlinkage long compat_sys_utime(const char __user *filename,
350be84cb43SChris Metcalf 				 struct compat_utimbuf __user *t);
351*4800a5bbSChris Metcalf asmlinkage long compat_sys_utimensat(unsigned int dfd,
352*4800a5bbSChris Metcalf 				     const char __user *filename,
353*4800a5bbSChris Metcalf 				     struct compat_timespec __user *t,
354*4800a5bbSChris Metcalf 				     int flags);
35597416ce8SStephen Rothwell 
356be84cb43SChris Metcalf asmlinkage long compat_sys_time(compat_time_t __user *tloc);
357be84cb43SChris Metcalf asmlinkage long compat_sys_stime(compat_time_t __user *tptr);
358140ff8b0SStephen Rothwell asmlinkage long compat_sys_signalfd(int ufd,
359140ff8b0SStephen Rothwell 				    const compat_sigset_t __user *sigmask,
360140ff8b0SStephen Rothwell 				    compat_size_t sigsetsize);
3614d672e7aSDavide Libenzi asmlinkage long compat_sys_timerfd_settime(int ufd, int flags,
3624d672e7aSDavide Libenzi 				   const struct compat_itimerspec __user *utmr,
3634d672e7aSDavide Libenzi 				   struct compat_itimerspec __user *otmr);
3644d672e7aSDavide Libenzi asmlinkage long compat_sys_timerfd_gettime(int ufd,
3654d672e7aSDavide Libenzi 				   struct compat_itimerspec __user *otmr);
366140ff8b0SStephen Rothwell 
3674c696ba7SHeiko Carstens asmlinkage long compat_sys_move_pages(pid_t pid, unsigned long nr_page,
3684c696ba7SHeiko Carstens 				      __u32 __user *pages,
3694c696ba7SHeiko Carstens 				      const int __user *nodes,
3704c696ba7SHeiko Carstens 				      int __user *status,
3714c696ba7SHeiko Carstens 				      int flags);
372*4800a5bbSChris Metcalf asmlinkage long compat_sys_futimesat(unsigned int dfd,
373*4800a5bbSChris Metcalf 				     const char __user *filename,
3744c696ba7SHeiko Carstens 				     struct compat_timeval __user *t);
375be84cb43SChris Metcalf asmlinkage long compat_sys_utimes(const char __user *filename,
376be84cb43SChris Metcalf 				  struct compat_timeval __user *t);
377be84cb43SChris Metcalf asmlinkage long compat_sys_newstat(const char __user *filename,
378be84cb43SChris Metcalf 				   struct compat_stat __user *statbuf);
379be84cb43SChris Metcalf asmlinkage long compat_sys_newlstat(const char __user *filename,
380be84cb43SChris Metcalf 				    struct compat_stat __user *statbuf);
381*4800a5bbSChris Metcalf asmlinkage long compat_sys_newfstatat(unsigned int dfd,
382*4800a5bbSChris Metcalf 				      const char __user *filename,
3834c696ba7SHeiko Carstens 				      struct compat_stat __user *statbuf,
3844c696ba7SHeiko Carstens 				      int flag);
385be84cb43SChris Metcalf asmlinkage long compat_sys_newfstat(unsigned int fd,
386be84cb43SChris Metcalf 				    struct compat_stat __user *statbuf);
387be84cb43SChris Metcalf asmlinkage long compat_sys_statfs(const char __user *pathname,
388be84cb43SChris Metcalf 				  struct compat_statfs __user *buf);
389be84cb43SChris Metcalf asmlinkage long compat_sys_fstatfs(unsigned int fd,
390be84cb43SChris Metcalf 				   struct compat_statfs __user *buf);
391be84cb43SChris Metcalf asmlinkage long compat_sys_statfs64(const char __user *pathname,
392be84cb43SChris Metcalf 				    compat_size_t sz,
393be84cb43SChris Metcalf 				    struct compat_statfs64 __user *buf);
394be84cb43SChris Metcalf asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
395be84cb43SChris Metcalf 				     struct compat_statfs64 __user *buf);
396be84cb43SChris Metcalf asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
397be84cb43SChris Metcalf 				   unsigned long arg);
398be84cb43SChris Metcalf asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
399be84cb43SChris Metcalf 				 unsigned long arg);
400be84cb43SChris Metcalf asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
401be84cb43SChris Metcalf asmlinkage long compat_sys_io_getevents(aio_context_t ctx_id,
402be84cb43SChris Metcalf 					unsigned long min_nr,
403be84cb43SChris Metcalf 					unsigned long nr,
404be84cb43SChris Metcalf 					struct io_event __user *events,
405be84cb43SChris Metcalf 					struct compat_timespec __user *timeout);
406be84cb43SChris Metcalf asmlinkage long compat_sys_io_submit(aio_context_t ctx_id, int nr,
407be84cb43SChris Metcalf 				     u32 __user *iocb);
408be84cb43SChris Metcalf asmlinkage long compat_sys_mount(const char __user *dev_name,
409be84cb43SChris Metcalf 				 const char __user *dir_name,
410be84cb43SChris Metcalf 				 const char __user *type, unsigned long flags,
411be84cb43SChris Metcalf 				 const void __user *data);
412be84cb43SChris Metcalf asmlinkage long compat_sys_old_readdir(unsigned int fd,
413be84cb43SChris Metcalf 				       struct compat_old_linux_dirent __user *,
414be84cb43SChris Metcalf 				       unsigned int count);
415be84cb43SChris Metcalf asmlinkage long compat_sys_getdents(unsigned int fd,
416be84cb43SChris Metcalf 				    struct compat_linux_dirent __user *dirent,
417be84cb43SChris Metcalf 				    unsigned int count);
418be84cb43SChris Metcalf asmlinkage long compat_sys_getdents64(unsigned int fd,
419be84cb43SChris Metcalf 				      struct linux_dirent64 __user *dirent,
420be84cb43SChris Metcalf 				      unsigned int count);
421be84cb43SChris Metcalf asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *,
422be84cb43SChris Metcalf 				    unsigned int nr_segs, unsigned int flags);
423be84cb43SChris Metcalf asmlinkage long compat_sys_open(const char __user *filename, int flags,
424be84cb43SChris Metcalf 				int mode);
4254c696ba7SHeiko Carstens asmlinkage long compat_sys_openat(unsigned int dfd, const char __user *filename,
4264c696ba7SHeiko Carstens 				  int flags, int mode);
427be84cb43SChris Metcalf asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
428be84cb43SChris Metcalf 					     struct file_handle __user *handle,
429be84cb43SChris Metcalf 					     int flags);
430be84cb43SChris Metcalf asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
431be84cb43SChris Metcalf 				    compat_ulong_t __user *outp,
432be84cb43SChris Metcalf 				    compat_ulong_t __user *exp,
433be84cb43SChris Metcalf 				    struct compat_timespec __user *tsp,
434be84cb43SChris Metcalf 				    void __user *sig);
435be84cb43SChris Metcalf asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
436be84cb43SChris Metcalf 				 unsigned int nfds,
437be84cb43SChris Metcalf 				 struct compat_timespec __user *tsp,
438be84cb43SChris Metcalf 				 const compat_sigset_t __user *sigmask,
439be84cb43SChris Metcalf 				 compat_size_t sigsetsize);
440*4800a5bbSChris Metcalf #if (defined(CONFIG_NFSD) || defined(CONFIG_NFSD_MODULE)) && \
441*4800a5bbSChris Metcalf 	!defined(CONFIG_NFSD_DEPRECATED)
442be84cb43SChris Metcalf union compat_nfsctl_res;
443be84cb43SChris Metcalf struct compat_nfsctl_arg;
444be84cb43SChris Metcalf asmlinkage long compat_sys_nfsservctl(int cmd,
445be84cb43SChris Metcalf 				      struct compat_nfsctl_arg __user *arg,
446be84cb43SChris Metcalf 				      union compat_nfsctl_res __user *res);
447be84cb43SChris Metcalf #else
448*4800a5bbSChris Metcalf asmlinkage long compat_sys_nfsservctl(int cmd, void *notused, void *notused2);
449be84cb43SChris Metcalf #endif
450be84cb43SChris Metcalf asmlinkage long compat_sys_signalfd4(int ufd,
451be84cb43SChris Metcalf 				     const compat_sigset_t __user *sigmask,
452be84cb43SChris Metcalf 				     compat_size_t sigsetsize, int flags);
453be84cb43SChris Metcalf asmlinkage long compat_sys_get_mempolicy(int __user *policy,
454be84cb43SChris Metcalf 					 compat_ulong_t __user *nmask,
455be84cb43SChris Metcalf 					 compat_ulong_t maxnode,
456be84cb43SChris Metcalf 					 compat_ulong_t addr,
457be84cb43SChris Metcalf 					 compat_ulong_t flags);
458be84cb43SChris Metcalf asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask,
459be84cb43SChris Metcalf 					 compat_ulong_t maxnode);
460be84cb43SChris Metcalf asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len,
461be84cb43SChris Metcalf 				 compat_ulong_t mode,
462be84cb43SChris Metcalf 				 compat_ulong_t __user *nmask,
463be84cb43SChris Metcalf 				 compat_ulong_t maxnode, compat_ulong_t flags);
464be84cb43SChris Metcalf 
465be84cb43SChris Metcalf asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
466be84cb43SChris Metcalf 				      char __user *optval, unsigned int optlen);
467be84cb43SChris Metcalf asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
468be84cb43SChris Metcalf 				   unsigned flags);
469be84cb43SChris Metcalf asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
470be84cb43SChris Metcalf 				   unsigned int flags);
471be84cb43SChris Metcalf asmlinkage long compat_sys_recv(int fd, void __user *buf, size_t len,
472be84cb43SChris Metcalf 				unsigned flags);
473be84cb43SChris Metcalf asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, size_t len,
474be84cb43SChris Metcalf 			    unsigned flags, struct sockaddr __user *addr,
475be84cb43SChris Metcalf 			    int __user *addrlen);
476be84cb43SChris Metcalf asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
477be84cb43SChris Metcalf 				    unsigned vlen, unsigned int flags,
478be84cb43SChris Metcalf 				    struct compat_timespec __user *timeout);
479be84cb43SChris Metcalf asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
480be84cb43SChris Metcalf 				     struct compat_timespec __user *rmtp);
481be84cb43SChris Metcalf asmlinkage long compat_sys_getitimer(int which,
482be84cb43SChris Metcalf 				     struct compat_itimerval __user *it);
483be84cb43SChris Metcalf asmlinkage long compat_sys_setitimer(int which,
484be84cb43SChris Metcalf 				     struct compat_itimerval __user *in,
485be84cb43SChris Metcalf 				     struct compat_itimerval __user *out);
486be84cb43SChris Metcalf asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
487be84cb43SChris Metcalf asmlinkage long compat_sys_setrlimit(unsigned int resource,
488be84cb43SChris Metcalf 				     struct compat_rlimit __user *rlim);
489be84cb43SChris Metcalf asmlinkage long compat_sys_getrlimit(unsigned int resource,
490be84cb43SChris Metcalf 				     struct compat_rlimit __user *rlim);
491be84cb43SChris Metcalf asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
492be84cb43SChris Metcalf asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
493be84cb43SChris Metcalf 				     unsigned int len,
494be84cb43SChris Metcalf 				     compat_ulong_t __user *user_mask_ptr);
495be84cb43SChris Metcalf asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
496be84cb43SChris Metcalf 				     unsigned int len,
497be84cb43SChris Metcalf 				     compat_ulong_t __user *user_mask_ptr);
498be84cb43SChris Metcalf asmlinkage long compat_sys_timer_create(clockid_t which_clock,
499be84cb43SChris Metcalf 			struct compat_sigevent __user *timer_event_spec,
500be84cb43SChris Metcalf 			timer_t __user *created_timer_id);
501be84cb43SChris Metcalf asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags,
502be84cb43SChris Metcalf 					 struct compat_itimerspec __user *new,
503be84cb43SChris Metcalf 					 struct compat_itimerspec __user *old);
504be84cb43SChris Metcalf asmlinkage long compat_sys_timer_gettime(timer_t timer_id,
505be84cb43SChris Metcalf 				 struct compat_itimerspec __user *setting);
506be84cb43SChris Metcalf asmlinkage long compat_sys_clock_settime(clockid_t which_clock,
507be84cb43SChris Metcalf 					 struct compat_timespec __user *tp);
508be84cb43SChris Metcalf asmlinkage long compat_sys_clock_gettime(clockid_t which_clock,
509be84cb43SChris Metcalf 					 struct compat_timespec __user *tp);
510be84cb43SChris Metcalf asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock,
511be84cb43SChris Metcalf 					 struct compat_timex __user *tp);
512be84cb43SChris Metcalf asmlinkage long compat_sys_clock_getres(clockid_t which_clock,
513be84cb43SChris Metcalf 					struct compat_timespec __user *tp);
514be84cb43SChris Metcalf asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
515be84cb43SChris Metcalf 					   struct compat_timespec __user *rqtp,
516be84cb43SChris Metcalf 					   struct compat_timespec __user *rmtp);
517be84cb43SChris Metcalf asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese,
518be84cb43SChris Metcalf 		struct compat_siginfo __user *uinfo,
519be84cb43SChris Metcalf 		struct compat_timespec __user *uts, compat_size_t sigsetsize);
520be84cb43SChris Metcalf asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
521be84cb43SChris Metcalf 					 compat_size_t sigsetsize);
522be84cb43SChris Metcalf asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
523be84cb43SChris Metcalf asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
524be84cb43SChris Metcalf 				 unsigned long arg);
525be84cb43SChris Metcalf asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val,
526be84cb43SChris Metcalf 		struct compat_timespec __user *utime, u32 __user *uaddr2,
527be84cb43SChris Metcalf 		u32 val3);
528be84cb43SChris Metcalf asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
529be84cb43SChris Metcalf 				      char __user *optval, int __user *optlen);
530be84cb43SChris Metcalf asmlinkage long compat_sys_kexec_load(unsigned long entry,
531be84cb43SChris Metcalf 				      unsigned long nr_segments,
532be84cb43SChris Metcalf 				      struct compat_kexec_segment __user *,
533be84cb43SChris Metcalf 				      unsigned long flags);
534be84cb43SChris Metcalf asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
535be84cb43SChris Metcalf 			const struct compat_mq_attr __user *u_mqstat,
536be84cb43SChris Metcalf 			struct compat_mq_attr __user *u_omqstat);
537be84cb43SChris Metcalf asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
538be84cb43SChris Metcalf 			const struct compat_sigevent __user *u_notification);
539be84cb43SChris Metcalf asmlinkage long compat_sys_mq_open(const char __user *u_name,
540be84cb43SChris Metcalf 			int oflag, compat_mode_t mode,
541be84cb43SChris Metcalf 			struct compat_mq_attr __user *u_attr);
542be84cb43SChris Metcalf asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes,
543be84cb43SChris Metcalf 			const char __user *u_msg_ptr,
544be84cb43SChris Metcalf 			size_t msg_len, unsigned int msg_prio,
545be84cb43SChris Metcalf 			const struct compat_timespec __user *u_abs_timeout);
546be84cb43SChris Metcalf asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes,
547be84cb43SChris Metcalf 			char __user *u_msg_ptr,
548be84cb43SChris Metcalf 			size_t msg_len, unsigned int __user *u_msg_prio,
549be84cb43SChris Metcalf 			const struct compat_timespec __user *u_abs_timeout);
550be84cb43SChris Metcalf asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
551be84cb43SChris Metcalf asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args);
5524c696ba7SHeiko Carstens 
553b8373363SJeff Moyer extern ssize_t compat_rw_copy_check_uvector(int type,
554*4800a5bbSChris Metcalf 		const struct compat_iovec __user *uvector,
555*4800a5bbSChris Metcalf 		unsigned long nr_segs,
556b8373363SJeff Moyer 		unsigned long fast_segs, struct iovec *fast_pointer,
557b8373363SJeff Moyer 		struct iovec **ret_pointer);
558c41d68a5SH. Peter Anvin 
559c41d68a5SH. Peter Anvin extern void __user *compat_alloc_user_space(unsigned long len);
560c41d68a5SH. Peter Anvin 
5611da177e4SLinus Torvalds #endif /* CONFIG_COMPAT */
5621da177e4SLinus Torvalds #endif /* _LINUX_COMPAT_H */
563