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 ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \ 38 asmlinkage long compat_sys_##name(void) 39 40 #define COMPAT_SYSCALL_DEFINE1(name, ...) \ 41 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__) 42 #define COMPAT_SYSCALL_DEFINE2(name, ...) \ 43 COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__) 44 #define COMPAT_SYSCALL_DEFINE3(name, ...) \ 45 COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__) 46 #define COMPAT_SYSCALL_DEFINE4(name, ...) \ 47 COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__) 48 #define COMPAT_SYSCALL_DEFINE5(name, ...) \ 49 COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__) 50 #define COMPAT_SYSCALL_DEFINE6(name, ...) \ 51 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__) 52 53 #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ 54 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ 55 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\ 56 __attribute__((alias(__stringify(compat_SyS##name)))); \ 57 ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \ 58 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__));\ 59 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__));\ 60 asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\ 61 { \ 62 return C_SYSC##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__)); \ 63 } \ 64 static inline long C_SYSC##name(__MAP(x,__SC_DECL,__VA_ARGS__)) 65 66 #ifndef compat_user_stack_pointer 67 #define compat_user_stack_pointer() current_user_stack_pointer() 68 #endif 69 #ifndef compat_sigaltstack /* we'll need that for MIPS */ 70 typedef struct compat_sigaltstack { 71 compat_uptr_t ss_sp; 72 int ss_flags; 73 compat_size_t ss_size; 74 } compat_stack_t; 75 #endif 76 77 #define compat_jiffies_to_clock_t(x) \ 78 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ) 79 80 typedef __compat_uid32_t compat_uid_t; 81 typedef __compat_gid32_t compat_gid_t; 82 83 typedef compat_ulong_t compat_aio_context_t; 84 85 struct compat_sel_arg_struct; 86 struct rusage; 87 88 struct compat_itimerspec { 89 struct compat_timespec it_interval; 90 struct compat_timespec it_value; 91 }; 92 93 struct compat_utimbuf { 94 compat_time_t actime; 95 compat_time_t modtime; 96 }; 97 98 struct compat_itimerval { 99 struct compat_timeval it_interval; 100 struct compat_timeval it_value; 101 }; 102 103 struct itimerval; 104 int get_compat_itimerval(struct itimerval *, const struct compat_itimerval __user *); 105 int put_compat_itimerval(struct compat_itimerval __user *, const struct itimerval *); 106 107 struct compat_tms { 108 compat_clock_t tms_utime; 109 compat_clock_t tms_stime; 110 compat_clock_t tms_cutime; 111 compat_clock_t tms_cstime; 112 }; 113 114 struct compat_timex { 115 compat_uint_t modes; 116 compat_long_t offset; 117 compat_long_t freq; 118 compat_long_t maxerror; 119 compat_long_t esterror; 120 compat_int_t status; 121 compat_long_t constant; 122 compat_long_t precision; 123 compat_long_t tolerance; 124 struct compat_timeval time; 125 compat_long_t tick; 126 compat_long_t ppsfreq; 127 compat_long_t jitter; 128 compat_int_t shift; 129 compat_long_t stabil; 130 compat_long_t jitcnt; 131 compat_long_t calcnt; 132 compat_long_t errcnt; 133 compat_long_t stbcnt; 134 compat_int_t tai; 135 136 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32; 137 compat_int_t:32; compat_int_t:32; compat_int_t:32; compat_int_t:32; 138 compat_int_t:32; compat_int_t:32; compat_int_t:32; 139 }; 140 141 struct timex; 142 int compat_get_timex(struct timex *, const struct compat_timex __user *); 143 int compat_put_timex(struct compat_timex __user *, const struct timex *); 144 145 #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW) 146 147 typedef struct { 148 compat_sigset_word sig[_COMPAT_NSIG_WORDS]; 149 } compat_sigset_t; 150 151 struct compat_sigaction { 152 #ifndef __ARCH_HAS_IRIX_SIGACTION 153 compat_uptr_t sa_handler; 154 compat_ulong_t sa_flags; 155 #else 156 compat_uint_t sa_flags; 157 compat_uptr_t sa_handler; 158 #endif 159 #ifdef __ARCH_HAS_SA_RESTORER 160 compat_uptr_t sa_restorer; 161 #endif 162 compat_sigset_t sa_mask __packed; 163 }; 164 165 typedef union compat_sigval { 166 compat_int_t sival_int; 167 compat_uptr_t sival_ptr; 168 } compat_sigval_t; 169 170 typedef struct compat_siginfo { 171 int si_signo; 172 #ifndef __ARCH_HAS_SWAPPED_SIGINFO 173 int si_errno; 174 int si_code; 175 #else 176 int si_code; 177 int si_errno; 178 #endif 179 180 union { 181 int _pad[128/sizeof(int) - 3]; 182 183 /* kill() */ 184 struct { 185 compat_pid_t _pid; /* sender's pid */ 186 __compat_uid32_t _uid; /* sender's uid */ 187 } _kill; 188 189 /* POSIX.1b timers */ 190 struct { 191 compat_timer_t _tid; /* timer id */ 192 int _overrun; /* overrun count */ 193 compat_sigval_t _sigval; /* same as below */ 194 } _timer; 195 196 /* POSIX.1b signals */ 197 struct { 198 compat_pid_t _pid; /* sender's pid */ 199 __compat_uid32_t _uid; /* sender's uid */ 200 compat_sigval_t _sigval; 201 } _rt; 202 203 /* SIGCHLD */ 204 struct { 205 compat_pid_t _pid; /* which child */ 206 __compat_uid32_t _uid; /* sender's uid */ 207 int _status; /* exit code */ 208 compat_clock_t _utime; 209 compat_clock_t _stime; 210 } _sigchld; 211 212 #ifdef CONFIG_X86_X32_ABI 213 /* SIGCHLD (x32 version) */ 214 struct { 215 compat_pid_t _pid; /* which child */ 216 __compat_uid32_t _uid; /* sender's uid */ 217 int _status; /* exit code */ 218 compat_s64 _utime; 219 compat_s64 _stime; 220 } _sigchld_x32; 221 #endif 222 223 /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */ 224 struct { 225 compat_uptr_t _addr; /* faulting insn/memory ref. */ 226 #ifdef __ARCH_SI_TRAPNO 227 int _trapno; /* TRAP # which caused the signal */ 228 #endif 229 union { 230 /* 231 * used when si_code=BUS_MCEERR_AR or 232 * used when si_code=BUS_MCEERR_AO 233 */ 234 short int _addr_lsb; /* Valid LSB of the reported address. */ 235 /* used when si_code=SEGV_BNDERR */ 236 struct { 237 compat_uptr_t _dummy_bnd; 238 compat_uptr_t _lower; 239 compat_uptr_t _upper; 240 } _addr_bnd; 241 /* used when si_code=SEGV_PKUERR */ 242 struct { 243 compat_uptr_t _dummy_pkey; 244 u32 _pkey; 245 } _addr_pkey; 246 }; 247 } _sigfault; 248 249 /* SIGPOLL */ 250 struct { 251 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 252 int _fd; 253 } _sigpoll; 254 255 struct { 256 compat_uptr_t _call_addr; /* calling user insn */ 257 int _syscall; /* triggering system call number */ 258 unsigned int _arch; /* AUDIT_ARCH_* of syscall */ 259 } _sigsys; 260 } _sifields; 261 } compat_siginfo_t; 262 263 /* 264 * These functions operate on 32- or 64-bit specs depending on 265 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments. 266 */ 267 extern int compat_get_timespec(struct timespec *, const void __user *); 268 extern int compat_put_timespec(const struct timespec *, void __user *); 269 extern int compat_get_timeval(struct timeval *, const void __user *); 270 extern int compat_put_timeval(const struct timeval *, void __user *); 271 extern int compat_get_timespec64(struct timespec64 *, const void __user *); 272 extern int compat_put_timespec64(const struct timespec64 *, void __user *); 273 extern int get_compat_itimerspec64(struct itimerspec64 *its, 274 const struct compat_itimerspec __user *uits); 275 extern int put_compat_itimerspec64(const struct itimerspec64 *its, 276 struct compat_itimerspec __user *uits); 277 278 struct compat_iovec { 279 compat_uptr_t iov_base; 280 compat_size_t iov_len; 281 }; 282 283 struct compat_rlimit { 284 compat_ulong_t rlim_cur; 285 compat_ulong_t rlim_max; 286 }; 287 288 struct compat_rusage { 289 struct compat_timeval ru_utime; 290 struct compat_timeval ru_stime; 291 compat_long_t ru_maxrss; 292 compat_long_t ru_ixrss; 293 compat_long_t ru_idrss; 294 compat_long_t ru_isrss; 295 compat_long_t ru_minflt; 296 compat_long_t ru_majflt; 297 compat_long_t ru_nswap; 298 compat_long_t ru_inblock; 299 compat_long_t ru_oublock; 300 compat_long_t ru_msgsnd; 301 compat_long_t ru_msgrcv; 302 compat_long_t ru_nsignals; 303 compat_long_t ru_nvcsw; 304 compat_long_t ru_nivcsw; 305 }; 306 307 extern int put_compat_rusage(const struct rusage *, 308 struct compat_rusage __user *); 309 310 struct compat_siginfo; 311 312 struct compat_dirent { 313 u32 d_ino; 314 compat_off_t d_off; 315 u16 d_reclen; 316 char d_name[256]; 317 }; 318 319 struct 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 328 typedef 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 343 struct 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 352 struct 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 358 struct 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 379 struct compat_ifconf { 380 compat_int_t ifc_len; /* size of buffer */ 381 compat_caddr_t ifcbuf; 382 }; 383 384 struct compat_robust_list { 385 compat_uptr_t next; 386 }; 387 388 struct 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 395 struct 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 403 struct compat_keyctl_kdf_params { 404 compat_uptr_t hashname; 405 compat_uptr_t otherinfo; 406 __u32 otherinfolen; 407 __u32 __spare[8]; 408 }; 409 410 struct compat_statfs; 411 struct compat_statfs64; 412 struct compat_old_linux_dirent; 413 struct compat_linux_dirent; 414 struct linux_dirent64; 415 struct compat_msghdr; 416 struct compat_mmsghdr; 417 struct compat_sysinfo; 418 struct compat_sysctl_args; 419 struct compat_kexec_segment; 420 struct compat_mq_attr; 421 struct compat_msgbuf; 422 423 extern void compat_exit_robust_list(struct task_struct *curr); 424 425 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) 426 427 #define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG) 428 429 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask, 430 unsigned long bitmap_size); 431 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, 432 unsigned long bitmap_size); 433 int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from); 434 int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from); 435 int get_compat_sigevent(struct sigevent *event, 436 const struct compat_sigevent __user *u_event); 437 438 static inline int compat_timeval_compare(struct compat_timeval *lhs, 439 struct compat_timeval *rhs) 440 { 441 if (lhs->tv_sec < rhs->tv_sec) 442 return -1; 443 if (lhs->tv_sec > rhs->tv_sec) 444 return 1; 445 return lhs->tv_usec - rhs->tv_usec; 446 } 447 448 static inline int compat_timespec_compare(struct compat_timespec *lhs, 449 struct compat_timespec *rhs) 450 { 451 if (lhs->tv_sec < rhs->tv_sec) 452 return -1; 453 if (lhs->tv_sec > rhs->tv_sec) 454 return 1; 455 return lhs->tv_nsec - rhs->tv_nsec; 456 } 457 458 extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat); 459 460 /* 461 * Defined inline such that size can be compile time constant, which avoids 462 * CONFIG_HARDENED_USERCOPY complaining about copies from task_struct 463 */ 464 static inline int 465 put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set, 466 unsigned int size) 467 { 468 /* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */ 469 #ifdef __BIG_ENDIAN 470 compat_sigset_t v; 471 switch (_NSIG_WORDS) { 472 case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3]; 473 case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2]; 474 case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1]; 475 case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0]; 476 } 477 return copy_to_user(compat, &v, size) ? -EFAULT : 0; 478 #else 479 return copy_to_user(compat, set, size) ? -EFAULT : 0; 480 #endif 481 } 482 483 extern int compat_ptrace_request(struct task_struct *child, 484 compat_long_t request, 485 compat_ulong_t addr, compat_ulong_t data); 486 487 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 488 compat_ulong_t addr, compat_ulong_t data); 489 490 struct epoll_event; /* fortunately, this one is fixed-layout */ 491 492 extern ssize_t compat_rw_copy_check_uvector(int type, 493 const struct compat_iovec __user *uvector, 494 unsigned long nr_segs, 495 unsigned long fast_segs, struct iovec *fast_pointer, 496 struct iovec **ret_pointer); 497 498 extern void __user *compat_alloc_user_space(unsigned long len); 499 500 int compat_restore_altstack(const compat_stack_t __user *uss); 501 int __compat_save_altstack(compat_stack_t __user *, unsigned long); 502 #define compat_save_altstack_ex(uss, sp) do { \ 503 compat_stack_t __user *__uss = uss; \ 504 struct task_struct *t = current; \ 505 put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &__uss->ss_sp); \ 506 put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \ 507 put_user_ex(t->sas_ss_size, &__uss->ss_size); \ 508 if (t->sas_ss_flags & SS_AUTODISARM) \ 509 sas_ss_reset(t); \ 510 } while (0); 511 512 /* 513 * These syscall function prototypes are kept in the same order as 514 * include/uapi/asm-generic/unistd.h. Deprecated or obsolete system calls 515 * go below. 516 * 517 * Please note that these prototypes here are only provided for information 518 * purposes, for static analysis, and for linking from the syscall table. 519 * These functions should not be called elsewhere from kernel code. 520 */ 521 asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p); 522 asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr, 523 u32 __user *iocb); 524 asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id, 525 compat_long_t min_nr, 526 compat_long_t nr, 527 struct io_event __user *events, 528 struct compat_timespec __user *timeout); 529 530 /* fs/cookies.c */ 531 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t); 532 533 /* fs/eventpoll.c */ 534 asmlinkage long compat_sys_epoll_pwait(int epfd, 535 struct epoll_event __user *events, 536 int maxevents, int timeout, 537 const compat_sigset_t __user *sigmask, 538 compat_size_t sigsetsize); 539 540 /* fs/fcntl.c */ 541 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd, 542 compat_ulong_t arg); 543 asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd, 544 compat_ulong_t arg); 545 546 /* fs/ioctl.c */ 547 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, 548 compat_ulong_t arg); 549 550 /* fs/namespace.c */ 551 asmlinkage long compat_sys_mount(const char __user *dev_name, 552 const char __user *dir_name, 553 const char __user *type, compat_ulong_t flags, 554 const void __user *data); 555 556 /* fs/open.c */ 557 asmlinkage long compat_sys_statfs(const char __user *pathname, 558 struct compat_statfs __user *buf); 559 asmlinkage long compat_sys_statfs64(const char __user *pathname, 560 compat_size_t sz, 561 struct compat_statfs64 __user *buf); 562 asmlinkage long compat_sys_fstatfs(unsigned int fd, 563 struct compat_statfs __user *buf); 564 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, 565 struct compat_statfs64 __user *buf); 566 asmlinkage long compat_sys_truncate(const char __user *, compat_off_t); 567 asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t); 568 /* No generic prototype for truncate64, ftruncate64, fallocate */ 569 asmlinkage long compat_sys_openat(int dfd, const char __user *filename, 570 int flags, umode_t mode); 571 572 /* fs/readdir.c */ 573 asmlinkage long compat_sys_getdents(unsigned int fd, 574 struct compat_linux_dirent __user *dirent, 575 unsigned int count); 576 577 /* fs/read_write.c */ 578 asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int); 579 asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd, 580 const struct compat_iovec __user *vec, compat_ulong_t vlen); 581 asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd, 582 const struct compat_iovec __user *vec, compat_ulong_t vlen); 583 /* No generic prototype for pread64 and pwrite64 */ 584 asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd, 585 const struct compat_iovec __user *vec, 586 compat_ulong_t vlen, u32 pos_low, u32 pos_high); 587 asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd, 588 const struct compat_iovec __user *vec, 589 compat_ulong_t vlen, u32 pos_low, u32 pos_high); 590 #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64 591 asmlinkage long compat_sys_preadv64(unsigned long fd, 592 const struct compat_iovec __user *vec, 593 unsigned long vlen, loff_t pos); 594 #endif 595 596 #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64 597 asmlinkage long compat_sys_pwritev64(unsigned long fd, 598 const struct compat_iovec __user *vec, 599 unsigned long vlen, loff_t pos); 600 #endif 601 602 /* fs/sendfile.c */ 603 asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, 604 compat_off_t __user *offset, compat_size_t count); 605 asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd, 606 compat_loff_t __user *offset, compat_size_t count); 607 608 /* fs/select.c */ 609 asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, 610 compat_ulong_t __user *outp, 611 compat_ulong_t __user *exp, 612 struct compat_timespec __user *tsp, 613 void __user *sig); 614 asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, 615 unsigned int nfds, 616 struct compat_timespec __user *tsp, 617 const compat_sigset_t __user *sigmask, 618 compat_size_t sigsetsize); 619 620 /* fs/signalfd.c */ 621 asmlinkage long compat_sys_signalfd4(int ufd, 622 const compat_sigset_t __user *sigmask, 623 compat_size_t sigsetsize, int flags); 624 625 /* fs/splice.c */ 626 asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *, 627 unsigned int nr_segs, unsigned int flags); 628 629 /* fs/stat.c */ 630 asmlinkage long compat_sys_newfstatat(unsigned int dfd, 631 const char __user *filename, 632 struct compat_stat __user *statbuf, 633 int flag); 634 asmlinkage long compat_sys_newfstat(unsigned int fd, 635 struct compat_stat __user *statbuf); 636 637 /* fs/sync.c: No generic prototype for sync_file_range and sync_file_range2 */ 638 639 /* fs/timerfd.c */ 640 asmlinkage long compat_sys_timerfd_gettime(int ufd, 641 struct compat_itimerspec __user *otmr); 642 asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, 643 const struct compat_itimerspec __user *utmr, 644 struct compat_itimerspec __user *otmr); 645 646 /* fs/utimes.c */ 647 asmlinkage long compat_sys_utimensat(unsigned int dfd, 648 const char __user *filename, 649 struct compat_timespec __user *t, 650 int flags); 651 652 /* kernel/exit.c */ 653 asmlinkage long compat_sys_waitid(int, compat_pid_t, 654 struct compat_siginfo __user *, int, 655 struct compat_rusage __user *); 656 657 658 659 /* kernel/futex.c */ 660 asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val, 661 struct compat_timespec __user *utime, u32 __user *uaddr2, 662 u32 val3); 663 asmlinkage long 664 compat_sys_set_robust_list(struct compat_robust_list_head __user *head, 665 compat_size_t len); 666 asmlinkage long 667 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, 668 compat_size_t __user *len_ptr); 669 670 /* kernel/hrtimer.c */ 671 asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, 672 struct compat_timespec __user *rmtp); 673 674 /* kernel/itimer.c */ 675 asmlinkage long compat_sys_getitimer(int which, 676 struct compat_itimerval __user *it); 677 asmlinkage long compat_sys_setitimer(int which, 678 struct compat_itimerval __user *in, 679 struct compat_itimerval __user *out); 680 681 /* kernel/kexec.c */ 682 asmlinkage long compat_sys_kexec_load(compat_ulong_t entry, 683 compat_ulong_t nr_segments, 684 struct compat_kexec_segment __user *, 685 compat_ulong_t flags); 686 687 /* kernel/posix-timers.c */ 688 asmlinkage long compat_sys_timer_create(clockid_t which_clock, 689 struct compat_sigevent __user *timer_event_spec, 690 timer_t __user *created_timer_id); 691 asmlinkage long compat_sys_timer_gettime(timer_t timer_id, 692 struct compat_itimerspec __user *setting); 693 asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags, 694 struct compat_itimerspec __user *new, 695 struct compat_itimerspec __user *old); 696 asmlinkage long compat_sys_clock_settime(clockid_t which_clock, 697 struct compat_timespec __user *tp); 698 asmlinkage long compat_sys_clock_gettime(clockid_t which_clock, 699 struct compat_timespec __user *tp); 700 asmlinkage long compat_sys_clock_getres(clockid_t which_clock, 701 struct compat_timespec __user *tp); 702 asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags, 703 struct compat_timespec __user *rqtp, 704 struct compat_timespec __user *rmtp); 705 706 /* kernel/ptrace.c */ 707 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, 708 compat_long_t addr, compat_long_t data); 709 710 /* kernel/sched/core.c */ 711 asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid, 712 unsigned int len, 713 compat_ulong_t __user *user_mask_ptr); 714 asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, 715 unsigned int len, 716 compat_ulong_t __user *user_mask_ptr); 717 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, 718 struct compat_timespec __user *interval); 719 720 /* kernel/signal.c */ 721 asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr, 722 compat_stack_t __user *uoss_ptr); 723 asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, 724 compat_size_t sigsetsize); 725 #ifndef CONFIG_ODD_RT_SIGACTION 726 asmlinkage long compat_sys_rt_sigaction(int, 727 const struct compat_sigaction __user *, 728 struct compat_sigaction __user *, 729 compat_size_t); 730 #endif 731 asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set, 732 compat_sigset_t __user *oset, 733 compat_size_t sigsetsize); 734 asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset, 735 compat_size_t sigsetsize); 736 asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese, 737 struct compat_siginfo __user *uinfo, 738 struct compat_timespec __user *uts, compat_size_t sigsetsize); 739 asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig, 740 struct compat_siginfo __user *uinfo); 741 /* No generic prototype for rt_sigreturn */ 742 743 /* kernel/sys.c */ 744 asmlinkage long compat_sys_times(struct compat_tms __user *tbuf); 745 asmlinkage long compat_sys_getrlimit(unsigned int resource, 746 struct compat_rlimit __user *rlim); 747 asmlinkage long compat_sys_setrlimit(unsigned int resource, 748 struct compat_rlimit __user *rlim); 749 asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru); 750 751 /* kernel/time.c */ 752 asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, 753 struct timezone __user *tz); 754 asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, 755 struct timezone __user *tz); 756 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 757 758 /* kernel/timer.c */ 759 asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info); 760 761 /* ipc/mqueue.c */ 762 asmlinkage long compat_sys_mq_open(const char __user *u_name, 763 int oflag, compat_mode_t mode, 764 struct compat_mq_attr __user *u_attr); 765 asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes, 766 const char __user *u_msg_ptr, 767 compat_size_t msg_len, unsigned int msg_prio, 768 const struct compat_timespec __user *u_abs_timeout); 769 asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes, 770 char __user *u_msg_ptr, 771 compat_size_t msg_len, unsigned int __user *u_msg_prio, 772 const struct compat_timespec __user *u_abs_timeout); 773 asmlinkage long compat_sys_mq_notify(mqd_t mqdes, 774 const struct compat_sigevent __user *u_notification); 775 asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes, 776 const struct compat_mq_attr __user *u_mqstat, 777 struct compat_mq_attr __user *u_omqstat); 778 779 /* ipc/msg.c */ 780 asmlinkage long compat_sys_msgctl(int first, int second, void __user *uptr); 781 asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp, 782 compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg); 783 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp, 784 compat_ssize_t msgsz, int msgflg); 785 786 /* ipc/sem.c */ 787 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg); 788 asmlinkage long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, 789 unsigned nsems, const struct compat_timespec __user *timeout); 790 791 /* ipc/shm.c */ 792 asmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr); 793 asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); 794 795 /* net/socket.c */ 796 asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len, 797 unsigned flags, struct sockaddr __user *addr, 798 int __user *addrlen); 799 asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, 800 char __user *optval, unsigned int optlen); 801 asmlinkage long compat_sys_getsockopt(int fd, int level, int optname, 802 char __user *optval, int __user *optlen); 803 asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, 804 unsigned flags); 805 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, 806 unsigned int flags); 807 808 /* mm/filemap.c: No generic prototype for readahead */ 809 810 /* security/keys/keyctl.c */ 811 asmlinkage long compat_sys_keyctl(u32 option, 812 u32 arg2, u32 arg3, u32 arg4, u32 arg5); 813 814 /* arch/example/kernel/sys_example.c */ 815 asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv, 816 const compat_uptr_t __user *envp); 817 818 /* mm/fadvise.c: No generic prototype for fadvise64_64 */ 819 820 /* mm/, CONFIG_MMU only */ 821 asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len, 822 compat_ulong_t mode, 823 compat_ulong_t __user *nmask, 824 compat_ulong_t maxnode, compat_ulong_t flags); 825 asmlinkage long compat_sys_get_mempolicy(int __user *policy, 826 compat_ulong_t __user *nmask, 827 compat_ulong_t maxnode, 828 compat_ulong_t addr, 829 compat_ulong_t flags); 830 asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask, 831 compat_ulong_t maxnode); 832 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, 833 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, 834 const compat_ulong_t __user *new_nodes); 835 asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages, 836 __u32 __user *pages, 837 const int __user *nodes, 838 int __user *status, 839 int flags); 840 841 asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, 842 compat_pid_t pid, int sig, 843 struct compat_siginfo __user *uinfo); 844 asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, 845 unsigned vlen, unsigned int flags, 846 struct compat_timespec __user *timeout); 847 asmlinkage long compat_sys_wait4(compat_pid_t pid, 848 compat_uint_t __user *stat_addr, int options, 849 struct compat_rusage __user *ru); 850 asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, 851 int, const char __user *); 852 asmlinkage long compat_sys_open_by_handle_at(int mountdirfd, 853 struct file_handle __user *handle, 854 int flags); 855 asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock, 856 struct compat_timex __user *tp); 857 asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg, 858 unsigned vlen, unsigned int flags); 859 asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid, 860 const struct compat_iovec __user *lvec, 861 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, 862 compat_ulong_t riovcnt, compat_ulong_t flags); 863 asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, 864 const struct compat_iovec __user *lvec, 865 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, 866 compat_ulong_t riovcnt, compat_ulong_t flags); 867 asmlinkage long compat_sys_execveat(int dfd, const char __user *filename, 868 const compat_uptr_t __user *argv, 869 const compat_uptr_t __user *envp, int flags); 870 asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd, 871 const struct compat_iovec __user *vec, 872 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); 873 asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd, 874 const struct compat_iovec __user *vec, 875 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); 876 #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2 877 asmlinkage long compat_sys_readv64v2(unsigned long fd, 878 const struct compat_iovec __user *vec, 879 unsigned long vlen, loff_t pos, rwf_t flags); 880 #endif 881 882 #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2 883 asmlinkage long compat_sys_pwritev64v2(unsigned long fd, 884 const struct compat_iovec __user *vec, 885 unsigned long vlen, loff_t pos, rwf_t flags); 886 #endif 887 888 889 /* 890 * Deprecated system calls which are still defined in 891 * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch 892 */ 893 894 /* __ARCH_WANT_SYSCALL_NO_AT */ 895 asmlinkage long compat_sys_open(const char __user *filename, int flags, 896 umode_t mode); 897 asmlinkage long compat_sys_utimes(const char __user *filename, 898 struct compat_timeval __user *t); 899 900 /* __ARCH_WANT_SYSCALL_NO_FLAGS */ 901 asmlinkage long compat_sys_signalfd(int ufd, 902 const compat_sigset_t __user *sigmask, 903 compat_size_t sigsetsize); 904 905 /* __ARCH_WANT_SYSCALL_OFF_T */ 906 asmlinkage long compat_sys_newstat(const char __user *filename, 907 struct compat_stat __user *statbuf); 908 asmlinkage long compat_sys_newlstat(const char __user *filename, 909 struct compat_stat __user *statbuf); 910 911 /* __ARCH_WANT_SYSCALL_DEPRECATED */ 912 asmlinkage long compat_sys_time(compat_time_t __user *tloc); 913 asmlinkage long compat_sys_utime(const char __user *filename, 914 struct compat_utimbuf __user *t); 915 asmlinkage long compat_sys_futimesat(unsigned int dfd, 916 const char __user *filename, 917 struct compat_timeval __user *t); 918 asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, 919 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 920 struct compat_timeval __user *tvp); 921 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32); 922 asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len, 923 unsigned flags); 924 asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args); 925 926 /* obsolete: fs/readdir.c */ 927 asmlinkage long compat_sys_old_readdir(unsigned int fd, 928 struct compat_old_linux_dirent __user *, 929 unsigned int count); 930 931 /* obsolete: fs/select.c */ 932 asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg); 933 934 /* obsolete: ipc */ 935 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32); 936 937 /* obsolete: kernel/signal.c */ 938 #ifdef __ARCH_WANT_SYS_SIGPENDING 939 asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set); 940 #endif 941 942 #ifdef __ARCH_WANT_SYS_SIGPROCMASK 943 asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset, 944 compat_old_sigset_t __user *oset); 945 #endif 946 #ifdef CONFIG_COMPAT_OLD_SIGACTION 947 asmlinkage long compat_sys_sigaction(int sig, 948 const struct compat_old_sigaction __user *act, 949 struct compat_old_sigaction __user *oact); 950 #endif 951 952 /* obsolete: kernel/time/time.c */ 953 asmlinkage long compat_sys_stime(compat_time_t __user *tptr); 954 955 /* obsolete: net/socket.c */ 956 asmlinkage long compat_sys_socketcall(int call, u32 __user *args); 957 958 959 /* 960 * For most but not all architectures, "am I in a compat syscall?" and 961 * "am I a compat task?" are the same question. For architectures on which 962 * they aren't the same question, arch code can override in_compat_syscall. 963 */ 964 965 #ifndef in_compat_syscall 966 static inline bool in_compat_syscall(void) { return is_compat_task(); } 967 #endif 968 969 /** 970 * ns_to_compat_timeval - Compat version of ns_to_timeval 971 * @nsec: the nanoseconds value to be converted 972 * 973 * Returns the compat_timeval representation of the nsec parameter. 974 */ 975 static inline struct compat_timeval ns_to_compat_timeval(s64 nsec) 976 { 977 struct timeval tv; 978 struct compat_timeval ctv; 979 980 tv = ns_to_timeval(nsec); 981 ctv.tv_sec = tv.tv_sec; 982 ctv.tv_usec = tv.tv_usec; 983 984 return ctv; 985 } 986 987 #else /* !CONFIG_COMPAT */ 988 989 #define is_compat_task() (0) 990 static inline bool in_compat_syscall(void) { return false; } 991 992 #endif /* CONFIG_COMPAT */ 993 994 #endif /* _LINUX_COMPAT_H */ 995