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 #define __COMPAT_ADDR_BND_PKEY_PAD (__alignof__(compat_uptr_t) < sizeof(short) ? \ 230 sizeof(short) : __alignof__(compat_uptr_t)) 231 union { 232 /* 233 * used when si_code=BUS_MCEERR_AR or 234 * used when si_code=BUS_MCEERR_AO 235 */ 236 short int _addr_lsb; /* Valid LSB of the reported address. */ 237 /* used when si_code=SEGV_BNDERR */ 238 struct { 239 char _dummy_bnd[__COMPAT_ADDR_BND_PKEY_PAD]; 240 compat_uptr_t _lower; 241 compat_uptr_t _upper; 242 } _addr_bnd; 243 /* used when si_code=SEGV_PKUERR */ 244 struct { 245 char _dummy_pkey[__COMPAT_ADDR_BND_PKEY_PAD]; 246 u32 _pkey; 247 } _addr_pkey; 248 }; 249 } _sigfault; 250 251 /* SIGPOLL */ 252 struct { 253 compat_long_t _band; /* POLL_IN, POLL_OUT, POLL_MSG */ 254 int _fd; 255 } _sigpoll; 256 257 struct { 258 compat_uptr_t _call_addr; /* calling user insn */ 259 int _syscall; /* triggering system call number */ 260 unsigned int _arch; /* AUDIT_ARCH_* of syscall */ 261 } _sigsys; 262 } _sifields; 263 } compat_siginfo_t; 264 265 /* 266 * These functions operate on 32- or 64-bit specs depending on 267 * COMPAT_USE_64BIT_TIME, hence the void user pointer arguments. 268 */ 269 extern int compat_get_timespec(struct timespec *, const void __user *); 270 extern int compat_put_timespec(const struct timespec *, void __user *); 271 extern int compat_get_timeval(struct timeval *, const void __user *); 272 extern int compat_put_timeval(const struct timeval *, void __user *); 273 extern int compat_get_timespec64(struct timespec64 *, const void __user *); 274 extern int compat_put_timespec64(const struct timespec64 *, void __user *); 275 extern int get_compat_itimerspec64(struct itimerspec64 *its, 276 const struct compat_itimerspec __user *uits); 277 extern int put_compat_itimerspec64(const struct itimerspec64 *its, 278 struct compat_itimerspec __user *uits); 279 280 struct compat_iovec { 281 compat_uptr_t iov_base; 282 compat_size_t iov_len; 283 }; 284 285 struct compat_rlimit { 286 compat_ulong_t rlim_cur; 287 compat_ulong_t rlim_max; 288 }; 289 290 struct compat_rusage { 291 struct compat_timeval ru_utime; 292 struct compat_timeval ru_stime; 293 compat_long_t ru_maxrss; 294 compat_long_t ru_ixrss; 295 compat_long_t ru_idrss; 296 compat_long_t ru_isrss; 297 compat_long_t ru_minflt; 298 compat_long_t ru_majflt; 299 compat_long_t ru_nswap; 300 compat_long_t ru_inblock; 301 compat_long_t ru_oublock; 302 compat_long_t ru_msgsnd; 303 compat_long_t ru_msgrcv; 304 compat_long_t ru_nsignals; 305 compat_long_t ru_nvcsw; 306 compat_long_t ru_nivcsw; 307 }; 308 309 extern int put_compat_rusage(const struct rusage *, 310 struct compat_rusage __user *); 311 312 struct compat_siginfo; 313 314 struct compat_dirent { 315 u32 d_ino; 316 compat_off_t d_off; 317 u16 d_reclen; 318 char d_name[256]; 319 }; 320 321 struct compat_ustat { 322 compat_daddr_t f_tfree; 323 compat_ino_t f_tinode; 324 char f_fname[6]; 325 char f_fpack[6]; 326 }; 327 328 #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3) 329 330 typedef struct compat_sigevent { 331 compat_sigval_t sigev_value; 332 compat_int_t sigev_signo; 333 compat_int_t sigev_notify; 334 union { 335 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE]; 336 compat_int_t _tid; 337 338 struct { 339 compat_uptr_t _function; 340 compat_uptr_t _attribute; 341 } _sigev_thread; 342 } _sigev_un; 343 } compat_sigevent_t; 344 345 struct compat_ifmap { 346 compat_ulong_t mem_start; 347 compat_ulong_t mem_end; 348 unsigned short base_addr; 349 unsigned char irq; 350 unsigned char dma; 351 unsigned char port; 352 }; 353 354 struct compat_if_settings { 355 unsigned int type; /* Type of physical device or protocol */ 356 unsigned int size; /* Size of the data allocated by the caller */ 357 compat_uptr_t ifs_ifsu; /* union of pointers */ 358 }; 359 360 struct compat_ifreq { 361 union { 362 char ifrn_name[IFNAMSIZ]; /* if name, e.g. "en0" */ 363 } ifr_ifrn; 364 union { 365 struct sockaddr ifru_addr; 366 struct sockaddr ifru_dstaddr; 367 struct sockaddr ifru_broadaddr; 368 struct sockaddr ifru_netmask; 369 struct sockaddr ifru_hwaddr; 370 short ifru_flags; 371 compat_int_t ifru_ivalue; 372 compat_int_t ifru_mtu; 373 struct compat_ifmap ifru_map; 374 char ifru_slave[IFNAMSIZ]; /* Just fits the size */ 375 char ifru_newname[IFNAMSIZ]; 376 compat_caddr_t ifru_data; 377 struct compat_if_settings ifru_settings; 378 } ifr_ifru; 379 }; 380 381 struct compat_ifconf { 382 compat_int_t ifc_len; /* size of buffer */ 383 compat_caddr_t ifcbuf; 384 }; 385 386 struct compat_robust_list { 387 compat_uptr_t next; 388 }; 389 390 struct compat_robust_list_head { 391 struct compat_robust_list list; 392 compat_long_t futex_offset; 393 compat_uptr_t list_op_pending; 394 }; 395 396 #ifdef CONFIG_COMPAT_OLD_SIGACTION 397 struct compat_old_sigaction { 398 compat_uptr_t sa_handler; 399 compat_old_sigset_t sa_mask; 400 compat_ulong_t sa_flags; 401 compat_uptr_t sa_restorer; 402 }; 403 #endif 404 405 struct compat_keyctl_kdf_params { 406 compat_uptr_t hashname; 407 compat_uptr_t otherinfo; 408 __u32 otherinfolen; 409 __u32 __spare[8]; 410 }; 411 412 struct compat_statfs; 413 struct compat_statfs64; 414 struct compat_old_linux_dirent; 415 struct compat_linux_dirent; 416 struct linux_dirent64; 417 struct compat_msghdr; 418 struct compat_mmsghdr; 419 struct compat_sysinfo; 420 struct compat_sysctl_args; 421 struct compat_kexec_segment; 422 struct compat_mq_attr; 423 struct compat_msgbuf; 424 425 extern void compat_exit_robust_list(struct task_struct *curr); 426 427 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t)) 428 429 #define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG) 430 431 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask, 432 unsigned long bitmap_size); 433 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask, 434 unsigned long bitmap_size); 435 int copy_siginfo_from_user32(siginfo_t *to, const struct compat_siginfo __user *from); 436 int copy_siginfo_to_user32(struct compat_siginfo __user *to, const siginfo_t *from); 437 int get_compat_sigevent(struct sigevent *event, 438 const struct compat_sigevent __user *u_event); 439 440 static inline int compat_timeval_compare(struct compat_timeval *lhs, 441 struct compat_timeval *rhs) 442 { 443 if (lhs->tv_sec < rhs->tv_sec) 444 return -1; 445 if (lhs->tv_sec > rhs->tv_sec) 446 return 1; 447 return lhs->tv_usec - rhs->tv_usec; 448 } 449 450 static inline int compat_timespec_compare(struct compat_timespec *lhs, 451 struct compat_timespec *rhs) 452 { 453 if (lhs->tv_sec < rhs->tv_sec) 454 return -1; 455 if (lhs->tv_sec > rhs->tv_sec) 456 return 1; 457 return lhs->tv_nsec - rhs->tv_nsec; 458 } 459 460 extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat); 461 462 /* 463 * Defined inline such that size can be compile time constant, which avoids 464 * CONFIG_HARDENED_USERCOPY complaining about copies from task_struct 465 */ 466 static inline int 467 put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set, 468 unsigned int size) 469 { 470 /* size <= sizeof(compat_sigset_t) <= sizeof(sigset_t) */ 471 #ifdef __BIG_ENDIAN 472 compat_sigset_t v; 473 switch (_NSIG_WORDS) { 474 case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3]; 475 case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2]; 476 case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1]; 477 case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0]; 478 } 479 return copy_to_user(compat, &v, size) ? -EFAULT : 0; 480 #else 481 return copy_to_user(compat, set, size) ? -EFAULT : 0; 482 #endif 483 } 484 485 extern int compat_ptrace_request(struct task_struct *child, 486 compat_long_t request, 487 compat_ulong_t addr, compat_ulong_t data); 488 489 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request, 490 compat_ulong_t addr, compat_ulong_t data); 491 492 struct epoll_event; /* fortunately, this one is fixed-layout */ 493 494 extern ssize_t compat_rw_copy_check_uvector(int type, 495 const struct compat_iovec __user *uvector, 496 unsigned long nr_segs, 497 unsigned long fast_segs, struct iovec *fast_pointer, 498 struct iovec **ret_pointer); 499 500 extern void __user *compat_alloc_user_space(unsigned long len); 501 502 int compat_restore_altstack(const compat_stack_t __user *uss); 503 int __compat_save_altstack(compat_stack_t __user *, unsigned long); 504 #define compat_save_altstack_ex(uss, sp) do { \ 505 compat_stack_t __user *__uss = uss; \ 506 struct task_struct *t = current; \ 507 put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &__uss->ss_sp); \ 508 put_user_ex(t->sas_ss_flags, &__uss->ss_flags); \ 509 put_user_ex(t->sas_ss_size, &__uss->ss_size); \ 510 if (t->sas_ss_flags & SS_AUTODISARM) \ 511 sas_ss_reset(t); \ 512 } while (0); 513 514 /* 515 * These syscall function prototypes are kept in the same order as 516 * include/uapi/asm-generic/unistd.h. Deprecated or obsolete system calls 517 * go below. 518 * 519 * Please note that these prototypes here are only provided for information 520 * purposes, for static analysis, and for linking from the syscall table. 521 * These functions should not be called elsewhere from kernel code. 522 */ 523 asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p); 524 asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr, 525 u32 __user *iocb); 526 asmlinkage long compat_sys_io_getevents(compat_aio_context_t ctx_id, 527 compat_long_t min_nr, 528 compat_long_t nr, 529 struct io_event __user *events, 530 struct compat_timespec __user *timeout); 531 532 /* fs/cookies.c */ 533 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t); 534 535 /* fs/eventpoll.c */ 536 asmlinkage long compat_sys_epoll_pwait(int epfd, 537 struct epoll_event __user *events, 538 int maxevents, int timeout, 539 const compat_sigset_t __user *sigmask, 540 compat_size_t sigsetsize); 541 542 /* fs/fcntl.c */ 543 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd, 544 compat_ulong_t arg); 545 asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd, 546 compat_ulong_t arg); 547 548 /* fs/ioctl.c */ 549 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, 550 compat_ulong_t arg); 551 552 /* fs/namespace.c */ 553 asmlinkage long compat_sys_mount(const char __user *dev_name, 554 const char __user *dir_name, 555 const char __user *type, compat_ulong_t flags, 556 const void __user *data); 557 558 /* fs/open.c */ 559 asmlinkage long compat_sys_statfs(const char __user *pathname, 560 struct compat_statfs __user *buf); 561 asmlinkage long compat_sys_statfs64(const char __user *pathname, 562 compat_size_t sz, 563 struct compat_statfs64 __user *buf); 564 asmlinkage long compat_sys_fstatfs(unsigned int fd, 565 struct compat_statfs __user *buf); 566 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz, 567 struct compat_statfs64 __user *buf); 568 asmlinkage long compat_sys_truncate(const char __user *, compat_off_t); 569 asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t); 570 /* No generic prototype for truncate64, ftruncate64, fallocate */ 571 asmlinkage long compat_sys_openat(int dfd, const char __user *filename, 572 int flags, umode_t mode); 573 574 /* fs/readdir.c */ 575 asmlinkage long compat_sys_getdents(unsigned int fd, 576 struct compat_linux_dirent __user *dirent, 577 unsigned int count); 578 579 /* fs/read_write.c */ 580 asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int); 581 asmlinkage ssize_t compat_sys_readv(compat_ulong_t fd, 582 const struct compat_iovec __user *vec, compat_ulong_t vlen); 583 asmlinkage ssize_t compat_sys_writev(compat_ulong_t fd, 584 const struct compat_iovec __user *vec, compat_ulong_t vlen); 585 /* No generic prototype for pread64 and pwrite64 */ 586 asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd, 587 const struct compat_iovec __user *vec, 588 compat_ulong_t vlen, u32 pos_low, u32 pos_high); 589 asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd, 590 const struct compat_iovec __user *vec, 591 compat_ulong_t vlen, u32 pos_low, u32 pos_high); 592 #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64 593 asmlinkage long compat_sys_preadv64(unsigned long fd, 594 const struct compat_iovec __user *vec, 595 unsigned long vlen, loff_t pos); 596 #endif 597 598 #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64 599 asmlinkage long compat_sys_pwritev64(unsigned long fd, 600 const struct compat_iovec __user *vec, 601 unsigned long vlen, loff_t pos); 602 #endif 603 604 /* fs/sendfile.c */ 605 asmlinkage long compat_sys_sendfile(int out_fd, int in_fd, 606 compat_off_t __user *offset, compat_size_t count); 607 asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd, 608 compat_loff_t __user *offset, compat_size_t count); 609 610 /* fs/select.c */ 611 asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp, 612 compat_ulong_t __user *outp, 613 compat_ulong_t __user *exp, 614 struct compat_timespec __user *tsp, 615 void __user *sig); 616 asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds, 617 unsigned int nfds, 618 struct compat_timespec __user *tsp, 619 const compat_sigset_t __user *sigmask, 620 compat_size_t sigsetsize); 621 622 /* fs/signalfd.c */ 623 asmlinkage long compat_sys_signalfd4(int ufd, 624 const compat_sigset_t __user *sigmask, 625 compat_size_t sigsetsize, int flags); 626 627 /* fs/splice.c */ 628 asmlinkage long compat_sys_vmsplice(int fd, const struct compat_iovec __user *, 629 unsigned int nr_segs, unsigned int flags); 630 631 /* fs/stat.c */ 632 asmlinkage long compat_sys_newfstatat(unsigned int dfd, 633 const char __user *filename, 634 struct compat_stat __user *statbuf, 635 int flag); 636 asmlinkage long compat_sys_newfstat(unsigned int fd, 637 struct compat_stat __user *statbuf); 638 639 /* fs/sync.c: No generic prototype for sync_file_range and sync_file_range2 */ 640 641 /* fs/timerfd.c */ 642 asmlinkage long compat_sys_timerfd_gettime(int ufd, 643 struct compat_itimerspec __user *otmr); 644 asmlinkage long compat_sys_timerfd_settime(int ufd, int flags, 645 const struct compat_itimerspec __user *utmr, 646 struct compat_itimerspec __user *otmr); 647 648 /* fs/utimes.c */ 649 asmlinkage long compat_sys_utimensat(unsigned int dfd, 650 const char __user *filename, 651 struct compat_timespec __user *t, 652 int flags); 653 654 /* kernel/exit.c */ 655 asmlinkage long compat_sys_waitid(int, compat_pid_t, 656 struct compat_siginfo __user *, int, 657 struct compat_rusage __user *); 658 659 660 661 /* kernel/futex.c */ 662 asmlinkage long compat_sys_futex(u32 __user *uaddr, int op, u32 val, 663 struct compat_timespec __user *utime, u32 __user *uaddr2, 664 u32 val3); 665 asmlinkage long 666 compat_sys_set_robust_list(struct compat_robust_list_head __user *head, 667 compat_size_t len); 668 asmlinkage long 669 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, 670 compat_size_t __user *len_ptr); 671 672 /* kernel/hrtimer.c */ 673 asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp, 674 struct compat_timespec __user *rmtp); 675 676 /* kernel/itimer.c */ 677 asmlinkage long compat_sys_getitimer(int which, 678 struct compat_itimerval __user *it); 679 asmlinkage long compat_sys_setitimer(int which, 680 struct compat_itimerval __user *in, 681 struct compat_itimerval __user *out); 682 683 /* kernel/kexec.c */ 684 asmlinkage long compat_sys_kexec_load(compat_ulong_t entry, 685 compat_ulong_t nr_segments, 686 struct compat_kexec_segment __user *, 687 compat_ulong_t flags); 688 689 /* kernel/posix-timers.c */ 690 asmlinkage long compat_sys_timer_create(clockid_t which_clock, 691 struct compat_sigevent __user *timer_event_spec, 692 timer_t __user *created_timer_id); 693 asmlinkage long compat_sys_timer_gettime(timer_t timer_id, 694 struct compat_itimerspec __user *setting); 695 asmlinkage long compat_sys_timer_settime(timer_t timer_id, int flags, 696 struct compat_itimerspec __user *new, 697 struct compat_itimerspec __user *old); 698 asmlinkage long compat_sys_clock_settime(clockid_t which_clock, 699 struct compat_timespec __user *tp); 700 asmlinkage long compat_sys_clock_gettime(clockid_t which_clock, 701 struct compat_timespec __user *tp); 702 asmlinkage long compat_sys_clock_getres(clockid_t which_clock, 703 struct compat_timespec __user *tp); 704 asmlinkage long compat_sys_clock_nanosleep(clockid_t which_clock, int flags, 705 struct compat_timespec __user *rqtp, 706 struct compat_timespec __user *rmtp); 707 708 /* kernel/ptrace.c */ 709 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid, 710 compat_long_t addr, compat_long_t data); 711 712 /* kernel/sched/core.c */ 713 asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid, 714 unsigned int len, 715 compat_ulong_t __user *user_mask_ptr); 716 asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid, 717 unsigned int len, 718 compat_ulong_t __user *user_mask_ptr); 719 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid, 720 struct compat_timespec __user *interval); 721 722 /* kernel/signal.c */ 723 asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr, 724 compat_stack_t __user *uoss_ptr); 725 asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset, 726 compat_size_t sigsetsize); 727 #ifndef CONFIG_ODD_RT_SIGACTION 728 asmlinkage long compat_sys_rt_sigaction(int, 729 const struct compat_sigaction __user *, 730 struct compat_sigaction __user *, 731 compat_size_t); 732 #endif 733 asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set, 734 compat_sigset_t __user *oset, 735 compat_size_t sigsetsize); 736 asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset, 737 compat_size_t sigsetsize); 738 asmlinkage long compat_sys_rt_sigtimedwait(compat_sigset_t __user *uthese, 739 struct compat_siginfo __user *uinfo, 740 struct compat_timespec __user *uts, compat_size_t sigsetsize); 741 asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig, 742 struct compat_siginfo __user *uinfo); 743 /* No generic prototype for rt_sigreturn */ 744 745 /* kernel/sys.c */ 746 asmlinkage long compat_sys_times(struct compat_tms __user *tbuf); 747 asmlinkage long compat_sys_getrlimit(unsigned int resource, 748 struct compat_rlimit __user *rlim); 749 asmlinkage long compat_sys_setrlimit(unsigned int resource, 750 struct compat_rlimit __user *rlim); 751 asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru); 752 753 /* kernel/time.c */ 754 asmlinkage long compat_sys_gettimeofday(struct compat_timeval __user *tv, 755 struct timezone __user *tz); 756 asmlinkage long compat_sys_settimeofday(struct compat_timeval __user *tv, 757 struct timezone __user *tz); 758 asmlinkage long compat_sys_adjtimex(struct compat_timex __user *utp); 759 760 /* kernel/timer.c */ 761 asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info); 762 763 /* ipc/mqueue.c */ 764 asmlinkage long compat_sys_mq_open(const char __user *u_name, 765 int oflag, compat_mode_t mode, 766 struct compat_mq_attr __user *u_attr); 767 asmlinkage long compat_sys_mq_timedsend(mqd_t mqdes, 768 const char __user *u_msg_ptr, 769 compat_size_t msg_len, unsigned int msg_prio, 770 const struct compat_timespec __user *u_abs_timeout); 771 asmlinkage ssize_t compat_sys_mq_timedreceive(mqd_t mqdes, 772 char __user *u_msg_ptr, 773 compat_size_t msg_len, unsigned int __user *u_msg_prio, 774 const struct compat_timespec __user *u_abs_timeout); 775 asmlinkage long compat_sys_mq_notify(mqd_t mqdes, 776 const struct compat_sigevent __user *u_notification); 777 asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes, 778 const struct compat_mq_attr __user *u_mqstat, 779 struct compat_mq_attr __user *u_omqstat); 780 781 /* ipc/msg.c */ 782 asmlinkage long compat_sys_msgctl(int first, int second, void __user *uptr); 783 asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp, 784 compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg); 785 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp, 786 compat_ssize_t msgsz, int msgflg); 787 788 /* ipc/sem.c */ 789 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg); 790 asmlinkage long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, 791 unsigned nsems, const struct compat_timespec __user *timeout); 792 793 /* ipc/shm.c */ 794 asmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr); 795 asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); 796 797 /* net/socket.c */ 798 asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len, 799 unsigned flags, struct sockaddr __user *addr, 800 int __user *addrlen); 801 asmlinkage long compat_sys_setsockopt(int fd, int level, int optname, 802 char __user *optval, unsigned int optlen); 803 asmlinkage long compat_sys_getsockopt(int fd, int level, int optname, 804 char __user *optval, int __user *optlen); 805 asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, 806 unsigned flags); 807 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg, 808 unsigned int flags); 809 810 /* mm/filemap.c: No generic prototype for readahead */ 811 812 /* security/keys/keyctl.c */ 813 asmlinkage long compat_sys_keyctl(u32 option, 814 u32 arg2, u32 arg3, u32 arg4, u32 arg5); 815 816 /* arch/example/kernel/sys_example.c */ 817 asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv, 818 const compat_uptr_t __user *envp); 819 820 /* mm/fadvise.c: No generic prototype for fadvise64_64 */ 821 822 /* mm/, CONFIG_MMU only */ 823 asmlinkage long compat_sys_mbind(compat_ulong_t start, compat_ulong_t len, 824 compat_ulong_t mode, 825 compat_ulong_t __user *nmask, 826 compat_ulong_t maxnode, compat_ulong_t flags); 827 asmlinkage long compat_sys_get_mempolicy(int __user *policy, 828 compat_ulong_t __user *nmask, 829 compat_ulong_t maxnode, 830 compat_ulong_t addr, 831 compat_ulong_t flags); 832 asmlinkage long compat_sys_set_mempolicy(int mode, compat_ulong_t __user *nmask, 833 compat_ulong_t maxnode); 834 asmlinkage long compat_sys_migrate_pages(compat_pid_t pid, 835 compat_ulong_t maxnode, const compat_ulong_t __user *old_nodes, 836 const compat_ulong_t __user *new_nodes); 837 asmlinkage long compat_sys_move_pages(pid_t pid, compat_ulong_t nr_pages, 838 __u32 __user *pages, 839 const int __user *nodes, 840 int __user *status, 841 int flags); 842 843 asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid, 844 compat_pid_t pid, int sig, 845 struct compat_siginfo __user *uinfo); 846 asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg, 847 unsigned vlen, unsigned int flags, 848 struct compat_timespec __user *timeout); 849 asmlinkage long compat_sys_wait4(compat_pid_t pid, 850 compat_uint_t __user *stat_addr, int options, 851 struct compat_rusage __user *ru); 852 asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32, 853 int, const char __user *); 854 asmlinkage long compat_sys_open_by_handle_at(int mountdirfd, 855 struct file_handle __user *handle, 856 int flags); 857 asmlinkage long compat_sys_clock_adjtime(clockid_t which_clock, 858 struct compat_timex __user *tp); 859 asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg, 860 unsigned vlen, unsigned int flags); 861 asmlinkage ssize_t compat_sys_process_vm_readv(compat_pid_t pid, 862 const struct compat_iovec __user *lvec, 863 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, 864 compat_ulong_t riovcnt, compat_ulong_t flags); 865 asmlinkage ssize_t compat_sys_process_vm_writev(compat_pid_t pid, 866 const struct compat_iovec __user *lvec, 867 compat_ulong_t liovcnt, const struct compat_iovec __user *rvec, 868 compat_ulong_t riovcnt, compat_ulong_t flags); 869 asmlinkage long compat_sys_execveat(int dfd, const char __user *filename, 870 const compat_uptr_t __user *argv, 871 const compat_uptr_t __user *envp, int flags); 872 asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd, 873 const struct compat_iovec __user *vec, 874 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); 875 asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd, 876 const struct compat_iovec __user *vec, 877 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags); 878 #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2 879 asmlinkage long compat_sys_readv64v2(unsigned long fd, 880 const struct compat_iovec __user *vec, 881 unsigned long vlen, loff_t pos, rwf_t flags); 882 #endif 883 884 #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2 885 asmlinkage long compat_sys_pwritev64v2(unsigned long fd, 886 const struct compat_iovec __user *vec, 887 unsigned long vlen, loff_t pos, rwf_t flags); 888 #endif 889 890 891 /* 892 * Deprecated system calls which are still defined in 893 * include/uapi/asm-generic/unistd.h and wanted by >= 1 arch 894 */ 895 896 /* __ARCH_WANT_SYSCALL_NO_AT */ 897 asmlinkage long compat_sys_open(const char __user *filename, int flags, 898 umode_t mode); 899 asmlinkage long compat_sys_utimes(const char __user *filename, 900 struct compat_timeval __user *t); 901 902 /* __ARCH_WANT_SYSCALL_NO_FLAGS */ 903 asmlinkage long compat_sys_signalfd(int ufd, 904 const compat_sigset_t __user *sigmask, 905 compat_size_t sigsetsize); 906 907 /* __ARCH_WANT_SYSCALL_OFF_T */ 908 asmlinkage long compat_sys_newstat(const char __user *filename, 909 struct compat_stat __user *statbuf); 910 asmlinkage long compat_sys_newlstat(const char __user *filename, 911 struct compat_stat __user *statbuf); 912 913 /* __ARCH_WANT_SYSCALL_DEPRECATED */ 914 asmlinkage long compat_sys_time(compat_time_t __user *tloc); 915 asmlinkage long compat_sys_utime(const char __user *filename, 916 struct compat_utimbuf __user *t); 917 asmlinkage long compat_sys_futimesat(unsigned int dfd, 918 const char __user *filename, 919 struct compat_timeval __user *t); 920 asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp, 921 compat_ulong_t __user *outp, compat_ulong_t __user *exp, 922 struct compat_timeval __user *tvp); 923 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32); 924 asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len, 925 unsigned flags); 926 asmlinkage long compat_sys_sysctl(struct compat_sysctl_args __user *args); 927 928 /* obsolete: fs/readdir.c */ 929 asmlinkage long compat_sys_old_readdir(unsigned int fd, 930 struct compat_old_linux_dirent __user *, 931 unsigned int count); 932 933 /* obsolete: fs/select.c */ 934 asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg); 935 936 /* obsolete: ipc */ 937 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32); 938 939 /* obsolete: kernel/signal.c */ 940 #ifdef __ARCH_WANT_SYS_SIGPENDING 941 asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set); 942 #endif 943 944 #ifdef __ARCH_WANT_SYS_SIGPROCMASK 945 asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset, 946 compat_old_sigset_t __user *oset); 947 #endif 948 #ifdef CONFIG_COMPAT_OLD_SIGACTION 949 asmlinkage long compat_sys_sigaction(int sig, 950 const struct compat_old_sigaction __user *act, 951 struct compat_old_sigaction __user *oact); 952 #endif 953 954 /* obsolete: kernel/time/time.c */ 955 asmlinkage long compat_sys_stime(compat_time_t __user *tptr); 956 957 /* obsolete: net/socket.c */ 958 asmlinkage long compat_sys_socketcall(int call, u32 __user *args); 959 960 961 /* 962 * For most but not all architectures, "am I in a compat syscall?" and 963 * "am I a compat task?" are the same question. For architectures on which 964 * they aren't the same question, arch code can override in_compat_syscall. 965 */ 966 967 #ifndef in_compat_syscall 968 static inline bool in_compat_syscall(void) { return is_compat_task(); } 969 #endif 970 971 /** 972 * ns_to_compat_timeval - Compat version of ns_to_timeval 973 * @nsec: the nanoseconds value to be converted 974 * 975 * Returns the compat_timeval representation of the nsec parameter. 976 */ 977 static inline struct compat_timeval ns_to_compat_timeval(s64 nsec) 978 { 979 struct timeval tv; 980 struct compat_timeval ctv; 981 982 tv = ns_to_timeval(nsec); 983 ctv.tv_sec = tv.tv_sec; 984 ctv.tv_usec = tv.tv_usec; 985 986 return ctv; 987 } 988 989 #else /* !CONFIG_COMPAT */ 990 991 #define is_compat_task() (0) 992 static inline bool in_compat_syscall(void) { return false; } 993 994 #endif /* CONFIG_COMPAT */ 995 996 #endif /* _LINUX_COMPAT_H */ 997