0001
0002 #ifndef _LINUX_COMPAT_H
0003 #define _LINUX_COMPAT_H
0004
0005
0006
0007
0008
0009 #include <linux/types.h>
0010 #include <linux/time.h>
0011
0012 #include <linux/stat.h>
0013 #include <linux/param.h> /* for HZ */
0014 #include <linux/sem.h>
0015 #include <linux/socket.h>
0016 #include <linux/if.h>
0017 #include <linux/fs.h>
0018 #include <linux/aio_abi.h> /* for aio_context_t */
0019 #include <linux/uaccess.h>
0020 #include <linux/unistd.h>
0021
0022 #include <asm/compat.h>
0023 #include <asm/siginfo.h>
0024 #include <asm/signal.h>
0025
0026 #ifdef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
0027
0028
0029
0030
0031
0032
0033
0034 #include <asm/syscall_wrapper.h>
0035 #endif
0036
0037 #ifndef COMPAT_USE_64BIT_TIME
0038 #define COMPAT_USE_64BIT_TIME 0
0039 #endif
0040
0041 #ifndef __SC_DELOUSE
0042 #define __SC_DELOUSE(t,v) ((__force t)(unsigned long)(v))
0043 #endif
0044
0045 #ifndef COMPAT_SYSCALL_DEFINE0
0046 #define COMPAT_SYSCALL_DEFINE0(name) \
0047 asmlinkage long compat_sys_##name(void); \
0048 ALLOW_ERROR_INJECTION(compat_sys_##name, ERRNO); \
0049 asmlinkage long compat_sys_##name(void)
0050 #endif
0051
0052 #define COMPAT_SYSCALL_DEFINE1(name, ...) \
0053 COMPAT_SYSCALL_DEFINEx(1, _##name, __VA_ARGS__)
0054 #define COMPAT_SYSCALL_DEFINE2(name, ...) \
0055 COMPAT_SYSCALL_DEFINEx(2, _##name, __VA_ARGS__)
0056 #define COMPAT_SYSCALL_DEFINE3(name, ...) \
0057 COMPAT_SYSCALL_DEFINEx(3, _##name, __VA_ARGS__)
0058 #define COMPAT_SYSCALL_DEFINE4(name, ...) \
0059 COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__)
0060 #define COMPAT_SYSCALL_DEFINE5(name, ...) \
0061 COMPAT_SYSCALL_DEFINEx(5, _##name, __VA_ARGS__)
0062 #define COMPAT_SYSCALL_DEFINE6(name, ...) \
0063 COMPAT_SYSCALL_DEFINEx(6, _##name, __VA_ARGS__)
0064
0065
0066
0067
0068
0069
0070 #ifndef COMPAT_SYSCALL_DEFINEx
0071 #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \
0072 __diag_push(); \
0073 __diag_ignore(GCC, 8, "-Wattribute-alias", \
0074 "Type aliasing is used to sanitize syscall arguments");\
0075 asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \
0076 __attribute__((alias(__stringify(__se_compat_sys##name)))); \
0077 ALLOW_ERROR_INJECTION(compat_sys##name, ERRNO); \
0078 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__));\
0079 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \
0080 asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \
0081 { \
0082 long ret = __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\
0083 __MAP(x,__SC_TEST,__VA_ARGS__); \
0084 return ret; \
0085 } \
0086 __diag_pop(); \
0087 static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
0088 #endif
0089
0090 struct compat_iovec {
0091 compat_uptr_t iov_base;
0092 compat_size_t iov_len;
0093 };
0094
0095 #ifndef compat_user_stack_pointer
0096 #define compat_user_stack_pointer() current_user_stack_pointer()
0097 #endif
0098 #ifndef compat_sigaltstack
0099 typedef struct compat_sigaltstack {
0100 compat_uptr_t ss_sp;
0101 int ss_flags;
0102 compat_size_t ss_size;
0103 } compat_stack_t;
0104 #endif
0105 #ifndef COMPAT_MINSIGSTKSZ
0106 #define COMPAT_MINSIGSTKSZ MINSIGSTKSZ
0107 #endif
0108
0109 #define compat_jiffies_to_clock_t(x) \
0110 (((unsigned long)(x) * COMPAT_USER_HZ) / HZ)
0111
0112 typedef __compat_uid32_t compat_uid_t;
0113 typedef __compat_gid32_t compat_gid_t;
0114
0115 struct compat_sel_arg_struct;
0116 struct rusage;
0117
0118 struct old_itimerval32;
0119
0120 struct compat_tms {
0121 compat_clock_t tms_utime;
0122 compat_clock_t tms_stime;
0123 compat_clock_t tms_cutime;
0124 compat_clock_t tms_cstime;
0125 };
0126
0127 #define _COMPAT_NSIG_WORDS (_COMPAT_NSIG / _COMPAT_NSIG_BPW)
0128
0129 #ifndef compat_sigset_t
0130 typedef struct {
0131 compat_sigset_word sig[_COMPAT_NSIG_WORDS];
0132 } compat_sigset_t;
0133 #endif
0134
0135 int set_compat_user_sigmask(const compat_sigset_t __user *umask,
0136 size_t sigsetsize);
0137
0138 struct compat_sigaction {
0139 #ifndef __ARCH_HAS_IRIX_SIGACTION
0140 compat_uptr_t sa_handler;
0141 compat_ulong_t sa_flags;
0142 #else
0143 compat_uint_t sa_flags;
0144 compat_uptr_t sa_handler;
0145 #endif
0146 #ifdef __ARCH_HAS_SA_RESTORER
0147 compat_uptr_t sa_restorer;
0148 #endif
0149 compat_sigset_t sa_mask __packed;
0150 };
0151
0152 typedef union compat_sigval {
0153 compat_int_t sival_int;
0154 compat_uptr_t sival_ptr;
0155 } compat_sigval_t;
0156
0157 typedef struct compat_siginfo {
0158 int si_signo;
0159 #ifndef __ARCH_HAS_SWAPPED_SIGINFO
0160 int si_errno;
0161 int si_code;
0162 #else
0163 int si_code;
0164 int si_errno;
0165 #endif
0166
0167 union {
0168 int _pad[128/sizeof(int) - 3];
0169
0170
0171 struct {
0172 compat_pid_t _pid;
0173 __compat_uid32_t _uid;
0174 } _kill;
0175
0176
0177 struct {
0178 compat_timer_t _tid;
0179 int _overrun;
0180 compat_sigval_t _sigval;
0181 } _timer;
0182
0183
0184 struct {
0185 compat_pid_t _pid;
0186 __compat_uid32_t _uid;
0187 compat_sigval_t _sigval;
0188 } _rt;
0189
0190
0191 struct {
0192 compat_pid_t _pid;
0193 __compat_uid32_t _uid;
0194 int _status;
0195 compat_clock_t _utime;
0196 compat_clock_t _stime;
0197 } _sigchld;
0198
0199 #ifdef CONFIG_X86_X32_ABI
0200
0201 struct {
0202 compat_pid_t _pid;
0203 __compat_uid32_t _uid;
0204 int _status;
0205 compat_s64 _utime;
0206 compat_s64 _stime;
0207 } _sigchld_x32;
0208 #endif
0209
0210
0211 struct {
0212 compat_uptr_t _addr;
0213 #define __COMPAT_ADDR_BND_PKEY_PAD (__alignof__(compat_uptr_t) < sizeof(short) ? \
0214 sizeof(short) : __alignof__(compat_uptr_t))
0215 union {
0216
0217 int _trapno;
0218
0219
0220
0221
0222 short int _addr_lsb;
0223
0224 struct {
0225 char _dummy_bnd[__COMPAT_ADDR_BND_PKEY_PAD];
0226 compat_uptr_t _lower;
0227 compat_uptr_t _upper;
0228 } _addr_bnd;
0229
0230 struct {
0231 char _dummy_pkey[__COMPAT_ADDR_BND_PKEY_PAD];
0232 u32 _pkey;
0233 } _addr_pkey;
0234
0235 struct {
0236 compat_ulong_t _data;
0237 u32 _type;
0238 u32 _flags;
0239 } _perf;
0240 };
0241 } _sigfault;
0242
0243
0244 struct {
0245 compat_long_t _band;
0246 int _fd;
0247 } _sigpoll;
0248
0249 struct {
0250 compat_uptr_t _call_addr;
0251 int _syscall;
0252 unsigned int _arch;
0253 } _sigsys;
0254 } _sifields;
0255 } compat_siginfo_t;
0256
0257 struct compat_rlimit {
0258 compat_ulong_t rlim_cur;
0259 compat_ulong_t rlim_max;
0260 };
0261
0262 #ifdef __ARCH_NEED_COMPAT_FLOCK64_PACKED
0263 #define __ARCH_COMPAT_FLOCK64_PACK __attribute__((packed))
0264 #else
0265 #define __ARCH_COMPAT_FLOCK64_PACK
0266 #endif
0267
0268 struct compat_flock {
0269 short l_type;
0270 short l_whence;
0271 compat_off_t l_start;
0272 compat_off_t l_len;
0273 #ifdef __ARCH_COMPAT_FLOCK_EXTRA_SYSID
0274 __ARCH_COMPAT_FLOCK_EXTRA_SYSID
0275 #endif
0276 compat_pid_t l_pid;
0277 #ifdef __ARCH_COMPAT_FLOCK_PAD
0278 __ARCH_COMPAT_FLOCK_PAD
0279 #endif
0280 };
0281
0282 struct compat_flock64 {
0283 short l_type;
0284 short l_whence;
0285 compat_loff_t l_start;
0286 compat_loff_t l_len;
0287 compat_pid_t l_pid;
0288 #ifdef __ARCH_COMPAT_FLOCK64_PAD
0289 __ARCH_COMPAT_FLOCK64_PAD
0290 #endif
0291 } __ARCH_COMPAT_FLOCK64_PACK;
0292
0293 struct compat_rusage {
0294 struct old_timeval32 ru_utime;
0295 struct old_timeval32 ru_stime;
0296 compat_long_t ru_maxrss;
0297 compat_long_t ru_ixrss;
0298 compat_long_t ru_idrss;
0299 compat_long_t ru_isrss;
0300 compat_long_t ru_minflt;
0301 compat_long_t ru_majflt;
0302 compat_long_t ru_nswap;
0303 compat_long_t ru_inblock;
0304 compat_long_t ru_oublock;
0305 compat_long_t ru_msgsnd;
0306 compat_long_t ru_msgrcv;
0307 compat_long_t ru_nsignals;
0308 compat_long_t ru_nvcsw;
0309 compat_long_t ru_nivcsw;
0310 };
0311
0312 extern int put_compat_rusage(const struct rusage *,
0313 struct compat_rusage __user *);
0314
0315 struct compat_siginfo;
0316 struct __compat_aio_sigset;
0317
0318 struct compat_dirent {
0319 u32 d_ino;
0320 compat_off_t d_off;
0321 u16 d_reclen;
0322 char d_name[256];
0323 };
0324
0325 struct compat_ustat {
0326 compat_daddr_t f_tfree;
0327 compat_ino_t f_tinode;
0328 char f_fname[6];
0329 char f_fpack[6];
0330 };
0331
0332 #define COMPAT_SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE/sizeof(int)) - 3)
0333
0334 typedef struct compat_sigevent {
0335 compat_sigval_t sigev_value;
0336 compat_int_t sigev_signo;
0337 compat_int_t sigev_notify;
0338 union {
0339 compat_int_t _pad[COMPAT_SIGEV_PAD_SIZE];
0340 compat_int_t _tid;
0341
0342 struct {
0343 compat_uptr_t _function;
0344 compat_uptr_t _attribute;
0345 } _sigev_thread;
0346 } _sigev_un;
0347 } compat_sigevent_t;
0348
0349 struct compat_ifmap {
0350 compat_ulong_t mem_start;
0351 compat_ulong_t mem_end;
0352 unsigned short base_addr;
0353 unsigned char irq;
0354 unsigned char dma;
0355 unsigned char port;
0356 };
0357
0358 struct compat_if_settings {
0359 unsigned int type;
0360 unsigned int size;
0361 compat_uptr_t ifs_ifsu;
0362 };
0363
0364 struct compat_ifreq {
0365 union {
0366 char ifrn_name[IFNAMSIZ];
0367 } ifr_ifrn;
0368 union {
0369 struct sockaddr ifru_addr;
0370 struct sockaddr ifru_dstaddr;
0371 struct sockaddr ifru_broadaddr;
0372 struct sockaddr ifru_netmask;
0373 struct sockaddr ifru_hwaddr;
0374 short ifru_flags;
0375 compat_int_t ifru_ivalue;
0376 compat_int_t ifru_mtu;
0377 struct compat_ifmap ifru_map;
0378 char ifru_slave[IFNAMSIZ];
0379 char ifru_newname[IFNAMSIZ];
0380 compat_caddr_t ifru_data;
0381 struct compat_if_settings ifru_settings;
0382 } ifr_ifru;
0383 };
0384
0385 struct compat_ifconf {
0386 compat_int_t ifc_len;
0387 compat_caddr_t ifcbuf;
0388 };
0389
0390 struct compat_robust_list {
0391 compat_uptr_t next;
0392 };
0393
0394 struct compat_robust_list_head {
0395 struct compat_robust_list list;
0396 compat_long_t futex_offset;
0397 compat_uptr_t list_op_pending;
0398 };
0399
0400 #ifdef CONFIG_COMPAT_OLD_SIGACTION
0401 struct compat_old_sigaction {
0402 compat_uptr_t sa_handler;
0403 compat_old_sigset_t sa_mask;
0404 compat_ulong_t sa_flags;
0405 compat_uptr_t sa_restorer;
0406 };
0407 #endif
0408
0409 struct compat_keyctl_kdf_params {
0410 compat_uptr_t hashname;
0411 compat_uptr_t otherinfo;
0412 __u32 otherinfolen;
0413 __u32 __spare[8];
0414 };
0415
0416 struct compat_stat;
0417 struct compat_statfs;
0418 struct compat_statfs64;
0419 struct compat_old_linux_dirent;
0420 struct compat_linux_dirent;
0421 struct linux_dirent64;
0422 struct compat_msghdr;
0423 struct compat_mmsghdr;
0424 struct compat_sysinfo;
0425 struct compat_sysctl_args;
0426 struct compat_kexec_segment;
0427 struct compat_mq_attr;
0428 struct compat_msgbuf;
0429
0430 void copy_siginfo_to_external32(struct compat_siginfo *to,
0431 const struct kernel_siginfo *from);
0432 int copy_siginfo_from_user32(kernel_siginfo_t *to,
0433 const struct compat_siginfo __user *from);
0434 int __copy_siginfo_to_user32(struct compat_siginfo __user *to,
0435 const kernel_siginfo_t *from);
0436 #ifndef copy_siginfo_to_user32
0437 #define copy_siginfo_to_user32 __copy_siginfo_to_user32
0438 #endif
0439 int get_compat_sigevent(struct sigevent *event,
0440 const struct compat_sigevent __user *u_event);
0441
0442 extern int get_compat_sigset(sigset_t *set, const compat_sigset_t __user *compat);
0443
0444
0445
0446
0447
0448 static inline int
0449 put_compat_sigset(compat_sigset_t __user *compat, const sigset_t *set,
0450 unsigned int size)
0451 {
0452
0453 #if defined(__BIG_ENDIAN) && defined(CONFIG_64BIT)
0454 compat_sigset_t v;
0455 switch (_NSIG_WORDS) {
0456 case 4: v.sig[7] = (set->sig[3] >> 32); v.sig[6] = set->sig[3];
0457 fallthrough;
0458 case 3: v.sig[5] = (set->sig[2] >> 32); v.sig[4] = set->sig[2];
0459 fallthrough;
0460 case 2: v.sig[3] = (set->sig[1] >> 32); v.sig[2] = set->sig[1];
0461 fallthrough;
0462 case 1: v.sig[1] = (set->sig[0] >> 32); v.sig[0] = set->sig[0];
0463 }
0464 return copy_to_user(compat, &v, size) ? -EFAULT : 0;
0465 #else
0466 return copy_to_user(compat, set, size) ? -EFAULT : 0;
0467 #endif
0468 }
0469
0470 #ifdef CONFIG_CPU_BIG_ENDIAN
0471 #define unsafe_put_compat_sigset(compat, set, label) do { \
0472 compat_sigset_t __user *__c = compat; \
0473 const sigset_t *__s = set; \
0474 \
0475 switch (_NSIG_WORDS) { \
0476 case 4: \
0477 unsafe_put_user(__s->sig[3] >> 32, &__c->sig[7], label); \
0478 unsafe_put_user(__s->sig[3], &__c->sig[6], label); \
0479 fallthrough; \
0480 case 3: \
0481 unsafe_put_user(__s->sig[2] >> 32, &__c->sig[5], label); \
0482 unsafe_put_user(__s->sig[2], &__c->sig[4], label); \
0483 fallthrough; \
0484 case 2: \
0485 unsafe_put_user(__s->sig[1] >> 32, &__c->sig[3], label); \
0486 unsafe_put_user(__s->sig[1], &__c->sig[2], label); \
0487 fallthrough; \
0488 case 1: \
0489 unsafe_put_user(__s->sig[0] >> 32, &__c->sig[1], label); \
0490 unsafe_put_user(__s->sig[0], &__c->sig[0], label); \
0491 } \
0492 } while (0)
0493
0494 #define unsafe_get_compat_sigset(set, compat, label) do { \
0495 const compat_sigset_t __user *__c = compat; \
0496 compat_sigset_word hi, lo; \
0497 sigset_t *__s = set; \
0498 \
0499 switch (_NSIG_WORDS) { \
0500 case 4: \
0501 unsafe_get_user(lo, &__c->sig[7], label); \
0502 unsafe_get_user(hi, &__c->sig[6], label); \
0503 __s->sig[3] = hi | (((long)lo) << 32); \
0504 fallthrough; \
0505 case 3: \
0506 unsafe_get_user(lo, &__c->sig[5], label); \
0507 unsafe_get_user(hi, &__c->sig[4], label); \
0508 __s->sig[2] = hi | (((long)lo) << 32); \
0509 fallthrough; \
0510 case 2: \
0511 unsafe_get_user(lo, &__c->sig[3], label); \
0512 unsafe_get_user(hi, &__c->sig[2], label); \
0513 __s->sig[1] = hi | (((long)lo) << 32); \
0514 fallthrough; \
0515 case 1: \
0516 unsafe_get_user(lo, &__c->sig[1], label); \
0517 unsafe_get_user(hi, &__c->sig[0], label); \
0518 __s->sig[0] = hi | (((long)lo) << 32); \
0519 } \
0520 } while (0)
0521 #else
0522 #define unsafe_put_compat_sigset(compat, set, label) do { \
0523 compat_sigset_t __user *__c = compat; \
0524 const sigset_t *__s = set; \
0525 \
0526 unsafe_copy_to_user(__c, __s, sizeof(*__c), label); \
0527 } while (0)
0528
0529 #define unsafe_get_compat_sigset(set, compat, label) do { \
0530 const compat_sigset_t __user *__c = compat; \
0531 sigset_t *__s = set; \
0532 \
0533 unsafe_copy_from_user(__s, __c, sizeof(*__c), label); \
0534 } while (0)
0535 #endif
0536
0537 extern int compat_ptrace_request(struct task_struct *child,
0538 compat_long_t request,
0539 compat_ulong_t addr, compat_ulong_t data);
0540
0541 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
0542 compat_ulong_t addr, compat_ulong_t data);
0543
0544 struct epoll_event;
0545
0546 int compat_restore_altstack(const compat_stack_t __user *uss);
0547 int __compat_save_altstack(compat_stack_t __user *, unsigned long);
0548 #define unsafe_compat_save_altstack(uss, sp, label) do { \
0549 compat_stack_t __user *__uss = uss; \
0550 struct task_struct *t = current; \
0551 unsafe_put_user(ptr_to_compat((void __user *)t->sas_ss_sp), \
0552 &__uss->ss_sp, label); \
0553 unsafe_put_user(t->sas_ss_flags, &__uss->ss_flags, label); \
0554 unsafe_put_user(t->sas_ss_size, &__uss->ss_size, label); \
0555 } while (0);
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569
0570 #ifndef CONFIG_ARCH_HAS_SYSCALL_WRAPPER
0571 asmlinkage long compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p);
0572 asmlinkage long compat_sys_io_submit(compat_aio_context_t ctx_id, int nr,
0573 u32 __user *iocb);
0574 asmlinkage long compat_sys_io_pgetevents(compat_aio_context_t ctx_id,
0575 compat_long_t min_nr,
0576 compat_long_t nr,
0577 struct io_event __user *events,
0578 struct old_timespec32 __user *timeout,
0579 const struct __compat_aio_sigset __user *usig);
0580 asmlinkage long compat_sys_io_pgetevents_time64(compat_aio_context_t ctx_id,
0581 compat_long_t min_nr,
0582 compat_long_t nr,
0583 struct io_event __user *events,
0584 struct __kernel_timespec __user *timeout,
0585 const struct __compat_aio_sigset __user *usig);
0586
0587
0588 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, compat_size_t);
0589
0590
0591 asmlinkage long compat_sys_epoll_pwait(int epfd,
0592 struct epoll_event __user *events,
0593 int maxevents, int timeout,
0594 const compat_sigset_t __user *sigmask,
0595 compat_size_t sigsetsize);
0596 asmlinkage long compat_sys_epoll_pwait2(int epfd,
0597 struct epoll_event __user *events,
0598 int maxevents,
0599 const struct __kernel_timespec __user *timeout,
0600 const compat_sigset_t __user *sigmask,
0601 compat_size_t sigsetsize);
0602
0603
0604 asmlinkage long compat_sys_fcntl(unsigned int fd, unsigned int cmd,
0605 compat_ulong_t arg);
0606 asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
0607 compat_ulong_t arg);
0608
0609
0610 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
0611 compat_ulong_t arg);
0612
0613
0614 asmlinkage long compat_sys_statfs(const char __user *pathname,
0615 struct compat_statfs __user *buf);
0616 asmlinkage long compat_sys_statfs64(const char __user *pathname,
0617 compat_size_t sz,
0618 struct compat_statfs64 __user *buf);
0619 asmlinkage long compat_sys_fstatfs(unsigned int fd,
0620 struct compat_statfs __user *buf);
0621 asmlinkage long compat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
0622 struct compat_statfs64 __user *buf);
0623 asmlinkage long compat_sys_truncate(const char __user *, compat_off_t);
0624 asmlinkage long compat_sys_ftruncate(unsigned int, compat_ulong_t);
0625
0626 asmlinkage long compat_sys_openat(int dfd, const char __user *filename,
0627 int flags, umode_t mode);
0628
0629
0630 asmlinkage long compat_sys_getdents(unsigned int fd,
0631 struct compat_linux_dirent __user *dirent,
0632 unsigned int count);
0633
0634
0635 asmlinkage long compat_sys_lseek(unsigned int, compat_off_t, unsigned int);
0636
0637 asmlinkage ssize_t compat_sys_preadv(compat_ulong_t fd,
0638 const struct iovec __user *vec,
0639 compat_ulong_t vlen, u32 pos_low, u32 pos_high);
0640 asmlinkage ssize_t compat_sys_pwritev(compat_ulong_t fd,
0641 const struct iovec __user *vec,
0642 compat_ulong_t vlen, u32 pos_low, u32 pos_high);
0643 #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64
0644 asmlinkage long compat_sys_preadv64(unsigned long fd,
0645 const struct iovec __user *vec,
0646 unsigned long vlen, loff_t pos);
0647 #endif
0648
0649 #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64
0650 asmlinkage long compat_sys_pwritev64(unsigned long fd,
0651 const struct iovec __user *vec,
0652 unsigned long vlen, loff_t pos);
0653 #endif
0654
0655
0656 asmlinkage long compat_sys_sendfile(int out_fd, int in_fd,
0657 compat_off_t __user *offset, compat_size_t count);
0658 asmlinkage long compat_sys_sendfile64(int out_fd, int in_fd,
0659 compat_loff_t __user *offset, compat_size_t count);
0660
0661
0662 asmlinkage long compat_sys_pselect6_time32(int n, compat_ulong_t __user *inp,
0663 compat_ulong_t __user *outp,
0664 compat_ulong_t __user *exp,
0665 struct old_timespec32 __user *tsp,
0666 void __user *sig);
0667 asmlinkage long compat_sys_pselect6_time64(int n, compat_ulong_t __user *inp,
0668 compat_ulong_t __user *outp,
0669 compat_ulong_t __user *exp,
0670 struct __kernel_timespec __user *tsp,
0671 void __user *sig);
0672 asmlinkage long compat_sys_ppoll_time32(struct pollfd __user *ufds,
0673 unsigned int nfds,
0674 struct old_timespec32 __user *tsp,
0675 const compat_sigset_t __user *sigmask,
0676 compat_size_t sigsetsize);
0677 asmlinkage long compat_sys_ppoll_time64(struct pollfd __user *ufds,
0678 unsigned int nfds,
0679 struct __kernel_timespec __user *tsp,
0680 const compat_sigset_t __user *sigmask,
0681 compat_size_t sigsetsize);
0682
0683
0684 asmlinkage long compat_sys_signalfd4(int ufd,
0685 const compat_sigset_t __user *sigmask,
0686 compat_size_t sigsetsize, int flags);
0687
0688
0689 asmlinkage long compat_sys_newfstatat(unsigned int dfd,
0690 const char __user *filename,
0691 struct compat_stat __user *statbuf,
0692 int flag);
0693 asmlinkage long compat_sys_newfstat(unsigned int fd,
0694 struct compat_stat __user *statbuf);
0695
0696
0697
0698
0699 asmlinkage long compat_sys_waitid(int, compat_pid_t,
0700 struct compat_siginfo __user *, int,
0701 struct compat_rusage __user *);
0702
0703
0704
0705
0706 asmlinkage long
0707 compat_sys_set_robust_list(struct compat_robust_list_head __user *head,
0708 compat_size_t len);
0709 asmlinkage long
0710 compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
0711 compat_size_t __user *len_ptr);
0712
0713
0714 asmlinkage long compat_sys_getitimer(int which,
0715 struct old_itimerval32 __user *it);
0716 asmlinkage long compat_sys_setitimer(int which,
0717 struct old_itimerval32 __user *in,
0718 struct old_itimerval32 __user *out);
0719
0720
0721 asmlinkage long compat_sys_kexec_load(compat_ulong_t entry,
0722 compat_ulong_t nr_segments,
0723 struct compat_kexec_segment __user *,
0724 compat_ulong_t flags);
0725
0726
0727 asmlinkage long compat_sys_timer_create(clockid_t which_clock,
0728 struct compat_sigevent __user *timer_event_spec,
0729 timer_t __user *created_timer_id);
0730
0731
0732 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
0733 compat_long_t addr, compat_long_t data);
0734
0735
0736 asmlinkage long compat_sys_sched_setaffinity(compat_pid_t pid,
0737 unsigned int len,
0738 compat_ulong_t __user *user_mask_ptr);
0739 asmlinkage long compat_sys_sched_getaffinity(compat_pid_t pid,
0740 unsigned int len,
0741 compat_ulong_t __user *user_mask_ptr);
0742
0743
0744 asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
0745 compat_stack_t __user *uoss_ptr);
0746 asmlinkage long compat_sys_rt_sigsuspend(compat_sigset_t __user *unewset,
0747 compat_size_t sigsetsize);
0748 #ifndef CONFIG_ODD_RT_SIGACTION
0749 asmlinkage long compat_sys_rt_sigaction(int,
0750 const struct compat_sigaction __user *,
0751 struct compat_sigaction __user *,
0752 compat_size_t);
0753 #endif
0754 asmlinkage long compat_sys_rt_sigprocmask(int how, compat_sigset_t __user *set,
0755 compat_sigset_t __user *oset,
0756 compat_size_t sigsetsize);
0757 asmlinkage long compat_sys_rt_sigpending(compat_sigset_t __user *uset,
0758 compat_size_t sigsetsize);
0759 asmlinkage long compat_sys_rt_sigtimedwait_time32(compat_sigset_t __user *uthese,
0760 struct compat_siginfo __user *uinfo,
0761 struct old_timespec32 __user *uts, compat_size_t sigsetsize);
0762 asmlinkage long compat_sys_rt_sigtimedwait_time64(compat_sigset_t __user *uthese,
0763 struct compat_siginfo __user *uinfo,
0764 struct __kernel_timespec __user *uts, compat_size_t sigsetsize);
0765 asmlinkage long compat_sys_rt_sigqueueinfo(compat_pid_t pid, int sig,
0766 struct compat_siginfo __user *uinfo);
0767
0768
0769
0770 asmlinkage long compat_sys_times(struct compat_tms __user *tbuf);
0771 asmlinkage long compat_sys_getrlimit(unsigned int resource,
0772 struct compat_rlimit __user *rlim);
0773 asmlinkage long compat_sys_setrlimit(unsigned int resource,
0774 struct compat_rlimit __user *rlim);
0775 asmlinkage long compat_sys_getrusage(int who, struct compat_rusage __user *ru);
0776
0777
0778 asmlinkage long compat_sys_gettimeofday(struct old_timeval32 __user *tv,
0779 struct timezone __user *tz);
0780 asmlinkage long compat_sys_settimeofday(struct old_timeval32 __user *tv,
0781 struct timezone __user *tz);
0782
0783
0784 asmlinkage long compat_sys_sysinfo(struct compat_sysinfo __user *info);
0785
0786
0787 asmlinkage long compat_sys_mq_open(const char __user *u_name,
0788 int oflag, compat_mode_t mode,
0789 struct compat_mq_attr __user *u_attr);
0790 asmlinkage long compat_sys_mq_notify(mqd_t mqdes,
0791 const struct compat_sigevent __user *u_notification);
0792 asmlinkage long compat_sys_mq_getsetattr(mqd_t mqdes,
0793 const struct compat_mq_attr __user *u_mqstat,
0794 struct compat_mq_attr __user *u_omqstat);
0795
0796
0797 asmlinkage long compat_sys_msgctl(int first, int second, void __user *uptr);
0798 asmlinkage long compat_sys_msgrcv(int msqid, compat_uptr_t msgp,
0799 compat_ssize_t msgsz, compat_long_t msgtyp, int msgflg);
0800 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
0801 compat_ssize_t msgsz, int msgflg);
0802
0803
0804 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
0805
0806
0807 asmlinkage long compat_sys_shmctl(int first, int second, void __user *uptr);
0808 asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
0809
0810
0811 asmlinkage long compat_sys_recvfrom(int fd, void __user *buf, compat_size_t len,
0812 unsigned flags, struct sockaddr __user *addr,
0813 int __user *addrlen);
0814 asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg,
0815 unsigned flags);
0816 asmlinkage long compat_sys_recvmsg(int fd, struct compat_msghdr __user *msg,
0817 unsigned int flags);
0818
0819
0820
0821
0822 asmlinkage long compat_sys_keyctl(u32 option,
0823 u32 arg2, u32 arg3, u32 arg4, u32 arg5);
0824
0825
0826 asmlinkage long compat_sys_execve(const char __user *filename, const compat_uptr_t __user *argv,
0827 const compat_uptr_t __user *envp);
0828
0829
0830
0831
0832 asmlinkage long compat_sys_rt_tgsigqueueinfo(compat_pid_t tgid,
0833 compat_pid_t pid, int sig,
0834 struct compat_siginfo __user *uinfo);
0835 asmlinkage long compat_sys_recvmmsg_time64(int fd, struct compat_mmsghdr __user *mmsg,
0836 unsigned vlen, unsigned int flags,
0837 struct __kernel_timespec __user *timeout);
0838 asmlinkage long compat_sys_recvmmsg_time32(int fd, struct compat_mmsghdr __user *mmsg,
0839 unsigned vlen, unsigned int flags,
0840 struct old_timespec32 __user *timeout);
0841 asmlinkage long compat_sys_wait4(compat_pid_t pid,
0842 compat_uint_t __user *stat_addr, int options,
0843 struct compat_rusage __user *ru);
0844 asmlinkage long compat_sys_fanotify_mark(int, unsigned int, __u32, __u32,
0845 int, const char __user *);
0846 asmlinkage long compat_sys_open_by_handle_at(int mountdirfd,
0847 struct file_handle __user *handle,
0848 int flags);
0849 asmlinkage long compat_sys_sendmmsg(int fd, struct compat_mmsghdr __user *mmsg,
0850 unsigned vlen, unsigned int flags);
0851 asmlinkage long compat_sys_execveat(int dfd, const char __user *filename,
0852 const compat_uptr_t __user *argv,
0853 const compat_uptr_t __user *envp, int flags);
0854 asmlinkage ssize_t compat_sys_preadv2(compat_ulong_t fd,
0855 const struct iovec __user *vec,
0856 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
0857 asmlinkage ssize_t compat_sys_pwritev2(compat_ulong_t fd,
0858 const struct iovec __user *vec,
0859 compat_ulong_t vlen, u32 pos_low, u32 pos_high, rwf_t flags);
0860 #ifdef __ARCH_WANT_COMPAT_SYS_PREADV64V2
0861 asmlinkage long compat_sys_preadv64v2(unsigned long fd,
0862 const struct iovec __user *vec,
0863 unsigned long vlen, loff_t pos, rwf_t flags);
0864 #endif
0865
0866 #ifdef __ARCH_WANT_COMPAT_SYS_PWRITEV64V2
0867 asmlinkage long compat_sys_pwritev64v2(unsigned long fd,
0868 const struct iovec __user *vec,
0869 unsigned long vlen, loff_t pos, rwf_t flags);
0870 #endif
0871
0872
0873
0874
0875
0876
0877
0878
0879 asmlinkage long compat_sys_open(const char __user *filename, int flags,
0880 umode_t mode);
0881
0882
0883 asmlinkage long compat_sys_signalfd(int ufd,
0884 const compat_sigset_t __user *sigmask,
0885 compat_size_t sigsetsize);
0886
0887
0888 asmlinkage long compat_sys_newstat(const char __user *filename,
0889 struct compat_stat __user *statbuf);
0890 asmlinkage long compat_sys_newlstat(const char __user *filename,
0891 struct compat_stat __user *statbuf);
0892
0893
0894 asmlinkage long compat_sys_select(int n, compat_ulong_t __user *inp,
0895 compat_ulong_t __user *outp, compat_ulong_t __user *exp,
0896 struct old_timeval32 __user *tvp);
0897 asmlinkage long compat_sys_ustat(unsigned dev, struct compat_ustat __user *u32);
0898 asmlinkage long compat_sys_recv(int fd, void __user *buf, compat_size_t len,
0899 unsigned flags);
0900
0901
0902 asmlinkage long compat_sys_old_readdir(unsigned int fd,
0903 struct compat_old_linux_dirent __user *,
0904 unsigned int count);
0905
0906
0907 asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg);
0908
0909
0910 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
0911
0912
0913 #ifdef __ARCH_WANT_SYS_SIGPENDING
0914 asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set);
0915 #endif
0916
0917 #ifdef __ARCH_WANT_SYS_SIGPROCMASK
0918 asmlinkage long compat_sys_sigprocmask(int how, compat_old_sigset_t __user *nset,
0919 compat_old_sigset_t __user *oset);
0920 #endif
0921 #ifdef CONFIG_COMPAT_OLD_SIGACTION
0922 asmlinkage long compat_sys_sigaction(int sig,
0923 const struct compat_old_sigaction __user *act,
0924 struct compat_old_sigaction __user *oact);
0925 #endif
0926
0927
0928 asmlinkage long compat_sys_socketcall(int call, u32 __user *args);
0929
0930 #ifdef __ARCH_WANT_COMPAT_TRUNCATE64
0931 asmlinkage long compat_sys_truncate64(const char __user *pathname, compat_arg_u64(len));
0932 #endif
0933
0934 #ifdef __ARCH_WANT_COMPAT_FTRUNCATE64
0935 asmlinkage long compat_sys_ftruncate64(unsigned int fd, compat_arg_u64(len));
0936 #endif
0937
0938 #ifdef __ARCH_WANT_COMPAT_FALLOCATE
0939 asmlinkage long compat_sys_fallocate(int fd, int mode, compat_arg_u64(offset),
0940 compat_arg_u64(len));
0941 #endif
0942
0943 #ifdef __ARCH_WANT_COMPAT_PREAD64
0944 asmlinkage long compat_sys_pread64(unsigned int fd, char __user *buf, size_t count,
0945 compat_arg_u64(pos));
0946 #endif
0947
0948 #ifdef __ARCH_WANT_COMPAT_PWRITE64
0949 asmlinkage long compat_sys_pwrite64(unsigned int fd, const char __user *buf, size_t count,
0950 compat_arg_u64(pos));
0951 #endif
0952
0953 #ifdef __ARCH_WANT_COMPAT_SYNC_FILE_RANGE
0954 asmlinkage long compat_sys_sync_file_range(int fd, compat_arg_u64(pos),
0955 compat_arg_u64(nbytes), unsigned int flags);
0956 #endif
0957
0958 #ifdef __ARCH_WANT_COMPAT_FADVISE64_64
0959 asmlinkage long compat_sys_fadvise64_64(int fd, compat_arg_u64(pos),
0960 compat_arg_u64(len), int advice);
0961 #endif
0962
0963 #ifdef __ARCH_WANT_COMPAT_READAHEAD
0964 asmlinkage long compat_sys_readahead(int fd, compat_arg_u64(offset), size_t count);
0965 #endif
0966
0967 #endif
0968
0969
0970
0971
0972
0973
0974
0975 static inline struct old_timeval32 ns_to_old_timeval32(s64 nsec)
0976 {
0977 struct __kernel_old_timeval tv;
0978 struct old_timeval32 ctv;
0979
0980 tv = ns_to_kernel_old_timeval(nsec);
0981 ctv.tv_sec = tv.tv_sec;
0982 ctv.tv_usec = tv.tv_usec;
0983
0984 return ctv;
0985 }
0986
0987
0988
0989
0990
0991
0992
0993 int kcompat_sys_statfs64(const char __user * pathname, compat_size_t sz,
0994 struct compat_statfs64 __user * buf);
0995 int kcompat_sys_fstatfs64(unsigned int fd, compat_size_t sz,
0996 struct compat_statfs64 __user * buf);
0997
0998 #ifdef CONFIG_COMPAT
0999
1000
1001
1002
1003
1004
1005 #ifndef in_compat_syscall
1006 static inline bool in_compat_syscall(void) { return is_compat_task(); }
1007 #endif
1008
1009 #else
1010
1011 #define is_compat_task() (0)
1012
1013 #define in_compat_syscall in_compat_syscall
1014 static inline bool in_compat_syscall(void) { return false; }
1015
1016 #endif
1017
1018 #define BITS_PER_COMPAT_LONG (8*sizeof(compat_long_t))
1019
1020 #define BITS_TO_COMPAT_LONGS(bits) DIV_ROUND_UP(bits, BITS_PER_COMPAT_LONG)
1021
1022 long compat_get_bitmap(unsigned long *mask, const compat_ulong_t __user *umask,
1023 unsigned long bitmap_size);
1024 long compat_put_bitmap(compat_ulong_t __user *umask, unsigned long *mask,
1025 unsigned long bitmap_size);
1026
1027
1028
1029
1030
1031
1032 #ifndef compat_need_64bit_alignment_fixup
1033 #define compat_need_64bit_alignment_fixup() false
1034 #endif
1035
1036
1037
1038
1039
1040
1041
1042 #ifndef compat_ptr
1043 static inline void __user *compat_ptr(compat_uptr_t uptr)
1044 {
1045 return (void __user *)(unsigned long)uptr;
1046 }
1047 #endif
1048
1049 static inline compat_uptr_t ptr_to_compat(void __user *uptr)
1050 {
1051 return (u32)(unsigned long)uptr;
1052 }
1053
1054 #endif