at v4.16 31 kB view raw
1/* SPDX-License-Identifier: GPL-2.0 */ 2#ifndef _LINUX_COMPAT_H 3#define _LINUX_COMPAT_H 4/* 5 * These are the type definitions for the architecture specific 6 * syscall compatibility layer. 7 */ 8 9#include <linux/types.h> 10 11#ifdef CONFIG_COMPAT 12 13#include <linux/stat.h> 14#include <linux/param.h> /* for HZ */ 15#include <linux/sem.h> 16#include <linux/socket.h> 17#include <linux/if.h> 18#include <linux/fs.h> 19#include <linux/aio_abi.h> /* for aio_context_t */ 20#include <linux/uaccess.h> 21#include <linux/unistd.h> 22 23#include <asm/compat.h> 24#include <asm/siginfo.h> 25#include <asm/signal.h> 26 27#ifndef COMPAT_USE_64BIT_TIME 28#define COMPAT_USE_64BIT_TIME 0 29#endif 30 31#ifndef __SC_DELOUSE 32#define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v)) 33#endif 34 35#define COMPAT_SYSCALL_DEFINE0(name) \ 36 asmlinkage long compat_sys_##name(void) 37 38#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 51#define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ 52 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\ 53 __attribute__((alias(__stringify(compat_SyS##name)))); \ 54 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ 55 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\ 56 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\ 57 { \ 58 return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ 59 } \ 60 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 61 62#ifndef compat_user_stack_pointer 63#define compat_user_stack_pointer() current_user_stack_pointer() 64#endif 65#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 72 73#define compat_jiffies_to_clock_t(x) \ 74 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) 75 76typedef __compat_uid32_t compat_uid_t; 77typedef __compat_gid32_t compat_gid_t; 78 79typedef compat_ulong_t compat_aio_context_t; 80 81struct compat_sel_arg_struct; 82struct rusage; 83 84struct compat_itimerspec { 85 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 99struct itimerval; 100int get_compat_itimerval(struct itimerval *, const struct compat_itimerval __user *); 101int put_compat_itimerval(struct compat_itimerval __user *, const struct itimerval *); 102 103struct 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 110struct 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; 130 compat_int_t tai; 131 132 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; 135}; 136 137struct timex; 138int compat_get_timex(struct timex *, const struct compat_timex __user *); 139int compat_put_timex(struct compat_timex __user *, const struct timex *); 140 141#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 147struct compat_sigaction { 148#ifndef __ARCH_HAS_IRIX_SIGACTION 149 compat_uptr_t sa_handler; 150 compat_ulong_t sa_flags; 151#else 152 compat_uint_t sa_flags; 153 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}; 160 161typedef 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 225 union { 226 /* 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. */ 231 /* used when si_code=SEGV_BNDERR */ 232 struct { 233 compat_uptr_t _dummy_bnd; 234 compat_uptr_t _lower; 235 compat_uptr_t _upper; 236 } _addr_bnd; 237 /* used when si_code=SEGV_PKUERR */ 238 struct { 239 compat_uptr_t _dummy_pkey; 240 u32 _pkey; 241 } _addr_pkey; 242 }; 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 259/* 260 * These functions operate on 32- or 64-bit specs depending on 261 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments. 262 */ 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 *); 267extern int compat_get_timespec64(struct timespec64 *, const void __user *); 268extern int compat_put_timespec64(const struct timespec64 *, void __user *); 269extern 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); 273 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 303extern int put_compat_rusage(const struct rusage *, 304 struct compat_rusage __user *); 305 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 319struct 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 326#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 343struct 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 352struct compat_if_settings { 353 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 358struct compat_ifreq { 359 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 */ 373 char ifru_newname[IFNAMSIZ]; 374 compat_caddr_t ifru_data; 375 struct compat_if_settings ifru_settings; 376 } ifr_ifru; 377}; 378 379struct compat_ifconf { 380 compat_int_t ifc_len; /* size of buffer */ 381 compat_caddr_t ifcbuf; 382}; 383 384struct 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 394#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 403struct compat_keyctl_kdf_params { 404 compat_uptr_t hashname; 405 compat_uptr_t otherinfo; 406 __u32 otherinfolen; 407 __u32 __spare[8]; 408}; 409 410struct 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; 421struct compat_msgbuf; 422 423extern 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 429compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, 430 compat_size_t __user *len_ptr); 431 432asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32); 433asmlinkage 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, 436 compat_ssize_t msgsz, int msgflg); 437asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp, 438 compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg); 439long compat_sys_msgctl(int first, int second, void __user *uptr); 440long 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); 445asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32); 446 447asmlinkage 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, 452 const struct compat_iovec __user *vec, 453 compat_ulong_t vlen, u32 pos_low, u32 pos_high); 454asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd, 455 const struct compat_iovec __user *vec, 456 compat_ulong_t vlen, u32 pos_low, u32 pos_high); 457asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd, 458 const struct compat_iovec __user *vec, 459 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); 460asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd, 461 const struct compat_iovec __user *vec, 462 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); 463 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 476#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 488asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int); 489 490asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv, 491 const compat_uptr_t __user *envp); 492asmlinkage 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); 495 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 500asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg); 501 502asmlinkage long compat_sys_wait4(compat_pid_t pid, 503 compat_uint_t __user *stat_addr, int options, 504 struct compat_rusage __user *ru); 505 506#define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) 507 508#define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG) 509 510long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask, 511 unsigned long bitmap_size); 512long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, 513 unsigned long bitmap_size); 514int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from); 515int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from); 516int get_compat_sigevent(struct sigevent *event, 517 const struct compat_sigevent __user *u_event); 518long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, compat_pid_t pid, int sig, 519 struct compat_siginfo __user *uinfo); 520#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 525 526static 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 546asmlinkage 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 551asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 552 553extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat); 554 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} 577 578asmlinkage 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 582extern int compat_ptrace_request(struct task_struct *child, 583 compat_long_t request, 584 compat_ulong_t addr, compat_ulong_t data); 585 586extern 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); 590 591asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t); 592/* 593 * epoll (fs/eventpoll.c) compat bits follow ... 594 */ 595struct epoll_event; /* fortunately, this one is fixed-layout */ 596asmlinkage long compat_sys_epoll_pwait(int epfd, 597 struct epoll_event __user *events, 598 int maxevents, int timeout, 599 const compat_sigset_t __user *sigmask, 600 compat_size_t sigsetsize); 601 602asmlinkage long compat_sys_utime(const char __user *filename, 603 struct compat_utimbuf __user *t); 604asmlinkage long compat_sys_utimensat(unsigned int dfd, 605 const char __user *filename, 606 struct compat_timespec __user *t, 607 int flags); 608 609asmlinkage long compat_sys_time(compat_time_t __user *tloc); 610asmlinkage long compat_sys_stime(compat_time_t __user *tptr); 611asmlinkage long compat_sys_signalfd(int ufd, 612 const compat_sigset_t __user *sigmask, 613 compat_size_t sigsetsize); 614asmlinkage 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); 619 620asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages, 621 __u32 __user *pages, 622 const int __user *nodes, 623 int __user *status, 624 int flags); 625asmlinkage long compat_sys_futimesat(unsigned int dfd, 626 const char __user *filename, 627 struct compat_timeval __user *t); 628asmlinkage long compat_sys_utimes(const char __user *filename, 629 struct compat_timeval __user *t); 630asmlinkage long compat_sys_newstat(const char __user *filename, 631 struct compat_stat __user *statbuf); 632asmlinkage long compat_sys_newlstat(const char __user *filename, 633 struct compat_stat __user *statbuf); 634asmlinkage long compat_sys_newfstatat(unsigned int dfd, 635 const char __user *filename, 636 struct compat_stat __user *statbuf, 637 int flag); 638asmlinkage long compat_sys_newfstat(unsigned int fd, 639 struct compat_stat __user *statbuf); 640asmlinkage 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, 650 compat_ulong_t arg); 651asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd, 652 compat_ulong_t arg); 653asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p); 654asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id, 655 compat_long_t min_nr, 656 compat_long_t nr, 657 struct io_event __user *events, 658 struct compat_timespec __user *timeout); 659asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr, 660 u32 __user *iocb); 661asmlinkage long compat_sys_mount(const char __user *dev_name, 662 const char __user *dir_name, 663 const char __user *type, compat_ulong_t flags, 664 const void __user *data); 665asmlinkage 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); 671asmlinkage 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, 674 umode_t mode); 675asmlinkage long compat_sys_openat(int dfd, const char __user *filename, 676 int flags, umode_t mode); 677asmlinkage long compat_sys_open_by_handle_at(int mountdirfd, 678 struct file_handle __user *handle, 679 int flags); 680asmlinkage long compat_sys_truncate(const char __user *, compat_off_t); 681asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t); 682asmlinkage 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); 692asmlinkage 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); 711asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg, 712 unsigned vlen, unsigned int flags); 713asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, 714 unsigned int flags); 715asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len, 716 unsigned flags); 717asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len, 718 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); 733asmlinkage long compat_sys_getrlimit(unsigned int resource, 734 struct compat_rlimit __user *rlim); 735asmlinkage 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); 761asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese, 762 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); 766asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set, 767 compat_sigset_t __user *oset, 768 compat_size_t sigsetsize); 769asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset, 770 compat_size_t sigsetsize); 771#ifndef CONFIG_ODD_RT_SIGACTION 772asmlinkage long compat_sys_rt_sigaction(int, 773 const struct compat_sigaction __user *, 774 struct compat_sigaction __user *, 775 compat_size_t); 776#endif 777asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig, 778 struct compat_siginfo __user *uinfo); 779asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info); 780asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, 781 compat_ulong_t arg); 782asmlinkage 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); 787asmlinkage long compat_sys_kexec_load(compat_ulong_t entry, 788 compat_ulong_t nr_segments, 789 struct compat_kexec_segment __user *, 790 compat_ulong_t flags); 791asmlinkage 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, 801 compat_size_t msg_len, unsigned int msg_prio, 802 const struct compat_timespec __user *u_abs_timeout); 803asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes, 804 char __user *u_msg_ptr, 805 compat_size_t msg_len, unsigned int __user *u_msg_prio, 806 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); 809 810extern ssize_t compat_rw_copy_check_uvector(int type, 811 const struct compat_iovec __user *uvector, 812 unsigned long nr_segs, 813 unsigned long fast_segs, struct iovec *fast_pointer, 814 struct iovec **ret_pointer); 815 816extern void __user *compat_alloc_user_space(unsigned long len); 817 818asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid, 819 const struct compat_iovec __user *lvec, 820 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, 821 compat_ulong_t riovcnt, compat_ulong_t flags); 822asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, 823 const struct compat_iovec __user *lvec, 824 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, 825 compat_ulong_t riovcnt, compat_ulong_t flags); 826 827asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, 828 compat_off_t __user *offset, compat_size_t count); 829asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd, 830 compat_loff_t __user *offset, compat_size_t count); 831asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr, 832 compat_stack_t __user *uoss_ptr); 833 834#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 843int compat_restore_altstack(const compat_stack_t __user *uss); 844int __compat_save_altstack(compat_stack_t __user *, unsigned long); 845#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); \ 849 put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \ 850 put_user_ex(t->sas_ss_size, &__uss->ss_size); \ 851 if (t->sas_ss_flags & SS_AUTODISARM) \ 852 sas_ss_reset(t); \ 853} while (0); 854 855asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, 856 struct compat_timespec __user *interval); 857 858asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, 859 int, const char __user *); 860 861asmlinkage long compat_sys_arch_prctl(int option, unsigned long arg2); 862 863/* 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 873/** 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 */ 892 893#define is_compat_task() (0) 894static inline bool in_compat_syscall(void) { return false; } 895 896#endif /* CONFIG_COMPAT */ 897 898#endif /* _LINUX_COMPAT_H */