^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * arch/arm/kernel/sys_oabi-compat.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Compatibility wrappers for syscalls that are used from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * old ABI user space binaries with an EABI kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Author: Nicolas Pitre
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Created: Oct 7, 2005
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * Copyright: MontaVista Software, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * The legacy ABI and the new ARM EABI have different rules making some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * syscalls incompatible especially with structure arguments.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * Most notably, Eabi says 64-bit members should be 64-bit aligned instead of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * simply word aligned. EABI also pads structures to the size of the largest
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * member it contains instead of the invariant 32-bit.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * The following syscalls are affected:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * sys_stat64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * sys_lstat64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * sys_fstat64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * sys_fstatat64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * struct stat64 has different sizes and some members are shifted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * Compatibility wrappers are needed for them and provided below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * sys_fcntl64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * struct flock64 has different sizes and some members are shifted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * A compatibility wrapper is needed and provided below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * sys_statfs64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * sys_fstatfs64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) * struct statfs64 has extra padding with EABI growing its size from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) * 84 to 88. This struct is now __attribute__((packed,aligned(4)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) * with a small assembly wrapper to force the sz argument to 84 if it is 88
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) * to avoid copying the extra padding over user space unexpecting it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) * sys_newuname:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) * struct new_utsname has no padding with EABI. No problem there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) * sys_epoll_ctl:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) * sys_epoll_wait:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * struct epoll_event has its second member shifted also affecting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * structure size. Compatibility wrappers are needed and provided below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * sys_ipc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * sys_semop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * sys_semtimedop:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * struct sembuf loses its padding with EABI. Since arrays of them are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * used they have to be copyed to remove the padding. Compatibility wrappers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * provided below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * sys_bind:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * sys_connect:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) * sys_sendmsg:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) * sys_sendto:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) * sys_socketcall:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) * struct sockaddr_un loses its padding with EABI. Since the size of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * structure is used as a validation test in unix_mkname(), we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * change the length argument to 110 whenever it is 112. Compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * wrappers provided below.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #include <linux/syscalls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #include <linux/cred.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #include <linux/fcntl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #include <linux/eventpoll.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #include <linux/sem.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #include <linux/socket.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #include <linux/net.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #include <linux/ipc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) struct oldabi_stat64 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long long st_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) unsigned int __pad1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) unsigned long __st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) unsigned int st_mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) unsigned int st_nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned long st_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) unsigned long st_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) unsigned long long st_rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) unsigned int __pad2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) long long st_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) unsigned long st_blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) unsigned long long st_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) unsigned long st_atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) unsigned long st_atime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) unsigned long st_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) unsigned long st_mtime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) unsigned long st_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) unsigned long st_ctime_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) unsigned long long st_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) } __attribute__ ((packed,aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static long cp_oldabi_stat64(struct kstat *stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) struct oldabi_stat64 __user *statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct oldabi_stat64 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) tmp.st_dev = huge_encode_dev(stat->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) tmp.__pad1 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) tmp.__st_ino = stat->ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) tmp.st_mode = stat->mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) tmp.st_nlink = stat->nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) tmp.st_uid = from_kuid_munged(current_user_ns(), stat->uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) tmp.st_gid = from_kgid_munged(current_user_ns(), stat->gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) tmp.st_rdev = huge_encode_dev(stat->rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) tmp.st_size = stat->size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) tmp.st_blocks = stat->blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) tmp.__pad2 = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) tmp.st_blksize = stat->blksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) tmp.st_atime = stat->atime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) tmp.st_atime_nsec = stat->atime.tv_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) tmp.st_mtime = stat->mtime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) tmp.st_mtime_nsec = stat->mtime.tv_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) tmp.st_ctime = stat->ctime.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) tmp.st_ctime_nsec = stat->ctime.tv_nsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) tmp.st_ino = stat->ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) return copy_to_user(statbuf,&tmp,sizeof(tmp)) ? -EFAULT : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) asmlinkage long sys_oabi_stat64(const char __user * filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) struct oldabi_stat64 __user * statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int error = vfs_stat(filename, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) error = cp_oldabi_stat64(&stat, statbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) asmlinkage long sys_oabi_lstat64(const char __user * filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct oldabi_stat64 __user * statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int error = vfs_lstat(filename, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) error = cp_oldabi_stat64(&stat, statbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) asmlinkage long sys_oabi_fstat64(unsigned long fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct oldabi_stat64 __user * statbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int error = vfs_fstat(fd, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) error = cp_oldabi_stat64(&stat, statbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) asmlinkage long sys_oabi_fstatat64(int dfd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) const char __user *filename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) struct oldabi_stat64 __user *statbuf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) int flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) error = vfs_fstatat(dfd, filename, &stat, flag);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return cp_oldabi_stat64(&stat, statbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct oabi_flock64 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) short l_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) short l_whence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) loff_t l_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) loff_t l_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) pid_t l_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) } __attribute__ ((packed,aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) static long do_locks(unsigned int fd, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) struct flock64 kernel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) struct oabi_flock64 user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) mm_segment_t fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) if (copy_from_user(&user, (struct oabi_flock64 __user *)arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) sizeof(user)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) kernel.l_type = user.l_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) kernel.l_whence = user.l_whence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) kernel.l_start = user.l_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) kernel.l_len = user.l_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) kernel.l_pid = user.l_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) fs = get_fs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) set_fs(KERNEL_DS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) ret = sys_fcntl64(fd, cmd, (unsigned long)&kernel);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) set_fs(fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) if (!ret && (cmd == F_GETLK64 || cmd == F_OFD_GETLK)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) user.l_type = kernel.l_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) user.l_whence = kernel.l_whence;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) user.l_start = kernel.l_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) user.l_len = kernel.l_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) user.l_pid = kernel.l_pid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) if (copy_to_user((struct oabi_flock64 __user *)arg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) &user, sizeof(user)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) unsigned long arg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) switch (cmd) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) case F_OFD_GETLK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) case F_OFD_SETLK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) case F_OFD_SETLKW:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) case F_GETLK64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) case F_SETLK64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) case F_SETLKW64:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) return do_locks(fd, cmd, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return sys_fcntl64(fd, cmd, arg);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) struct oabi_epoll_event {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) __u32 events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) __u64 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) } __attribute__ ((packed,aligned(4)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) #ifdef CONFIG_EPOLL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) asmlinkage long sys_oabi_epoll_ctl(int epfd, int op, int fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) struct oabi_epoll_event __user *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) struct oabi_epoll_event user;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) struct epoll_event kernel;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) if (ep_op_has_event(op) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) copy_from_user(&user, event, sizeof(user)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) kernel.events = user.events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) kernel.data = user.data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return do_epoll_ctl(epfd, op, fd, &kernel, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) asmlinkage long sys_oabi_epoll_wait(int epfd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct oabi_epoll_event __user *events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) int maxevents, int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) struct epoll_event *kbuf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) struct oabi_epoll_event e;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) mm_segment_t fs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) long ret, err, i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) if (maxevents <= 0 ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) maxevents > (INT_MAX/sizeof(*kbuf)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) maxevents > (INT_MAX/sizeof(*events)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) if (!access_ok(events, sizeof(*events) * maxevents))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (!kbuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) fs = get_fs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) set_fs(KERNEL_DS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) ret = sys_epoll_wait(epfd, kbuf, maxevents, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) set_fs(fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) for (i = 0; i < ret; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) e.events = kbuf[i].events;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) e.data = kbuf[i].data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) err = __copy_to_user(events, &e, sizeof(e));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) events++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) kfree(kbuf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) return err ? -EFAULT : ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) asmlinkage long sys_oabi_epoll_ctl(int epfd, int op, int fd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) struct oabi_epoll_event __user *event)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) asmlinkage long sys_oabi_epoll_wait(int epfd,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) struct oabi_epoll_event __user *events,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) int maxevents, int timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) struct oabi_sembuf {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) unsigned short sem_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) short sem_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) short sem_flg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) unsigned short __pad;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) asmlinkage long sys_oabi_semtimedop(int semid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) struct oabi_sembuf __user *tsops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) unsigned nsops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) const struct old_timespec32 __user *timeout)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) struct sembuf *sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) struct old_timespec32 local_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) long err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if (nsops < 1 || nsops > SEMOPM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) if (!access_ok(tsops, sizeof(*tsops) * nsops))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) return -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (!sops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) for (i = 0; i < nsops; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) struct oabi_sembuf osb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) err |= __copy_from_user(&osb, tsops, sizeof(osb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) sops[i].sem_num = osb.sem_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) sops[i].sem_op = osb.sem_op;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) sops[i].sem_flg = osb.sem_flg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) tsops++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) if (timeout) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /* copy this as well before changing domain protection */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) err |= copy_from_user(&local_timeout, timeout, sizeof(*timeout));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) timeout = &local_timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) err = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) mm_segment_t fs = get_fs();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) set_fs(KERNEL_DS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) err = sys_semtimedop_time32(semid, sops, nsops, timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) set_fs(fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) kfree(sops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) asmlinkage long sys_oabi_semop(int semid, struct oabi_sembuf __user *tsops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) unsigned nsops)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) return sys_oabi_semtimedop(semid, tsops, nsops, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) asmlinkage int sys_oabi_ipc(uint call, int first, int second, int third,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) void __user *ptr, long fifth)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) switch (call & 0xffff) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) case SEMOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) return sys_oabi_semtimedop(first,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) (struct oabi_sembuf __user *)ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) second, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) case SEMTIMEDOP:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return sys_oabi_semtimedop(first,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) (struct oabi_sembuf __user *)ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) second,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) (const struct old_timespec32 __user *)fifth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) return sys_ipc(call, first, second, third, ptr, fifth);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) asmlinkage long sys_oabi_bind(int fd, struct sockaddr __user *addr, int addrlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) sa_family_t sa_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) if (addrlen == 112 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) get_user(sa_family, &addr->sa_family) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) sa_family == AF_UNIX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) addrlen = 110;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return sys_bind(fd, addr, addrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) asmlinkage long sys_oabi_connect(int fd, struct sockaddr __user *addr, int addrlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) sa_family_t sa_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (addrlen == 112 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) get_user(sa_family, &addr->sa_family) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) sa_family == AF_UNIX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) addrlen = 110;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) return sys_connect(fd, addr, addrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) asmlinkage long sys_oabi_sendto(int fd, void __user *buff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) size_t len, unsigned flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) struct sockaddr __user *addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) int addrlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) sa_family_t sa_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) if (addrlen == 112 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) get_user(sa_family, &addr->sa_family) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) sa_family == AF_UNIX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) addrlen = 110;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) return sys_sendto(fd, buff, len, flags, addr, addrlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) asmlinkage long sys_oabi_sendmsg(int fd, struct user_msghdr __user *msg, unsigned flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) struct sockaddr __user *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) int msg_namelen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) sa_family_t sa_family;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) if (msg &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) get_user(msg_namelen, &msg->msg_namelen) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) msg_namelen == 112 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) get_user(addr, &msg->msg_name) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) get_user(sa_family, &addr->sa_family) == 0 &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) sa_family == AF_UNIX)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) * HACK ALERT: there is a limit to how much backward bending
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) * we should do for what is actually a transitional
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) * compatibility layer. This already has known flaws with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) * a few ioctls that we don't intend to fix. Therefore
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) * consider this blatent hack as another one... and take care
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) * to run for cover. In most cases it will "just work fine".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) * If it doesn't, well, tough.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) put_user(110, &msg->msg_namelen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return sys_sendmsg(fd, msg, flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) asmlinkage long sys_oabi_socketcall(int call, unsigned long __user *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) unsigned long r = -EFAULT, a[6];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) switch (call) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) case SYS_BIND:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) if (copy_from_user(a, args, 3 * sizeof(long)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) r = sys_oabi_bind(a[0], (struct sockaddr __user *)a[1], a[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) case SYS_CONNECT:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) if (copy_from_user(a, args, 3 * sizeof(long)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) r = sys_oabi_connect(a[0], (struct sockaddr __user *)a[1], a[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) case SYS_SENDTO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) if (copy_from_user(a, args, 6 * sizeof(long)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) r = sys_oabi_sendto(a[0], (void __user *)a[1], a[2], a[3],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) (struct sockaddr __user *)a[4], a[5]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) case SYS_SENDMSG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if (copy_from_user(a, args, 3 * sizeof(long)) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) r = sys_oabi_sendmsg(a[0], (struct user_msghdr __user *)a[1], a[2]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) r = sys_socketcall(call, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) return r;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }