ipc(2): move compat to native

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro 20bc2a3a 28327fae

+93 -95
+4 -94
ipc/compat.c
··· 39 39 char mtext[1]; 40 40 }; 41 41 42 - struct compat_ipc_kludge { 43 - compat_uptr_t msgp; 44 - compat_long_t msgtyp; 45 - }; 46 - 47 42 int get_compat_ipc64_perm(struct ipc64_perm *to, 48 43 struct compat_ipc64_perm __user *from) 49 44 { ··· 99 104 return msgsz; 100 105 } 101 106 102 - #ifndef COMPAT_SHMLBA 103 - #define COMPAT_SHMLBA SHMLBA 104 - #endif 105 - 106 - #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC 107 - COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second, 108 - u32, third, compat_uptr_t, ptr, u32, fifth) 109 - { 110 - int version; 111 - u32 pad; 112 - 113 - version = call >> 16; /* hack for backward compatibility */ 114 - call &= 0xffff; 115 - 116 - switch (call) { 117 - case SEMOP: 118 - /* struct sembuf is the same on 32 and 64bit :)) */ 119 - return sys_semtimedop(first, compat_ptr(ptr), second, NULL); 120 - case SEMTIMEDOP: 121 - return compat_sys_semtimedop(first, compat_ptr(ptr), second, 122 - compat_ptr(fifth)); 123 - case SEMGET: 124 - return sys_semget(first, second, third); 125 - case SEMCTL: 126 - if (!ptr) 127 - return -EINVAL; 128 - if (get_user(pad, (u32 __user *) compat_ptr(ptr))) 129 - return -EFAULT; 130 - return compat_sys_semctl(first, second, third, pad); 131 - 132 - case MSGSND: { 133 - struct compat_msgbuf __user *up = compat_ptr(ptr); 134 - compat_long_t type; 135 - 136 - if (first < 0 || second < 0) 137 - return -EINVAL; 138 - 139 - if (get_user(type, &up->mtype)) 140 - return -EFAULT; 141 - 142 - return do_msgsnd(first, type, up->mtext, second, third); 143 - } 144 - case MSGRCV: { 145 - void __user *uptr = compat_ptr(ptr); 146 - 147 - if (first < 0 || second < 0) 148 - return -EINVAL; 149 - 150 - if (!version) { 151 - struct compat_ipc_kludge ipck; 152 - if (!uptr) 153 - return -EINVAL; 154 - if (copy_from_user(&ipck, uptr, sizeof(ipck))) 155 - return -EFAULT; 156 - uptr = compat_ptr(ipck.msgp); 157 - fifth = ipck.msgtyp; 158 - } 159 - return do_msgrcv(first, uptr, second, (s32)fifth, third, 160 - compat_do_msg_fill); 161 - } 162 - case MSGGET: 163 - return sys_msgget(first, second); 164 - case MSGCTL: 165 - return compat_sys_msgctl(first, second, compat_ptr(ptr)); 166 - 167 - case SHMAT: { 168 - int err; 169 - unsigned long raddr; 170 - 171 - if (version == 1) 172 - return -EINVAL; 173 - err = do_shmat(first, compat_ptr(ptr), second, &raddr, 174 - COMPAT_SHMLBA); 175 - if (err < 0) 176 - return err; 177 - return put_user(raddr, (compat_ulong_t *)compat_ptr(third)); 178 - } 179 - case SHMDT: 180 - return sys_shmdt(compat_ptr(ptr)); 181 - case SHMGET: 182 - return sys_shmget(first, (unsigned)second, third); 183 - case SHMCTL: 184 - return compat_sys_shmctl(first, second, compat_ptr(ptr)); 185 - } 186 - 187 - return -ENOSYS; 188 - } 189 - #endif 190 - 191 107 COMPAT_SYSCALL_DEFINE4(msgsnd, int, msqid, compat_uptr_t, msgp, 192 108 compat_ssize_t, msgsz, int, msgflg) 193 109 { ··· 116 210 return do_msgrcv(msqid, compat_ptr(msgp), (ssize_t)msgsz, (long)msgtyp, 117 211 msgflg, compat_do_msg_fill); 118 212 } 213 + 214 + #ifndef COMPAT_SHMLBA 215 + #define COMPAT_SHMLBA SHMLBA 216 + #endif 119 217 120 218 COMPAT_SYSCALL_DEFINE3(shmat, int, shmid, compat_uptr_t, shmaddr, int, shmflg) 121 219 {
+89 -1
ipc/syscall.c
··· 5 5 * the individual syscalls instead. 6 6 */ 7 7 #include <linux/unistd.h> 8 + #include <linux/syscalls.h> 8 9 9 10 #ifdef __ARCH_WANT_SYS_IPC 10 11 #include <linux/errno.h> 11 12 #include <linux/ipc.h> 12 13 #include <linux/shm.h> 13 - #include <linux/syscalls.h> 14 14 #include <linux/uaccess.h> 15 15 16 16 SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second, ··· 96 96 return -ENOSYS; 97 97 } 98 98 } 99 + #endif 100 + 101 + #ifdef CONFIG_COMPAT 102 + #include <linux/compat.h> 103 + 104 + #ifndef COMPAT_SHMLBA 105 + #define COMPAT_SHMLBA SHMLBA 106 + #endif 107 + 108 + struct compat_ipc_kludge { 109 + compat_uptr_t msgp; 110 + compat_long_t msgtyp; 111 + }; 112 + 113 + #ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC 114 + COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second, 115 + u32, third, compat_uptr_t, ptr, u32, fifth) 116 + { 117 + int version; 118 + u32 pad; 119 + 120 + version = call >> 16; /* hack for backward compatibility */ 121 + call &= 0xffff; 122 + 123 + switch (call) { 124 + case SEMOP: 125 + /* struct sembuf is the same on 32 and 64bit :)) */ 126 + return sys_semtimedop(first, compat_ptr(ptr), second, NULL); 127 + case SEMTIMEDOP: 128 + return compat_sys_semtimedop(first, compat_ptr(ptr), second, 129 + compat_ptr(fifth)); 130 + case SEMGET: 131 + return sys_semget(first, second, third); 132 + case SEMCTL: 133 + if (!ptr) 134 + return -EINVAL; 135 + if (get_user(pad, (u32 __user *) compat_ptr(ptr))) 136 + return -EFAULT; 137 + return compat_sys_semctl(first, second, third, pad); 138 + 139 + case MSGSND: 140 + return compat_sys_msgsnd(first, ptr, second, third); 141 + 142 + case MSGRCV: { 143 + void __user *uptr = compat_ptr(ptr); 144 + 145 + if (first < 0 || second < 0) 146 + return -EINVAL; 147 + 148 + if (!version) { 149 + struct compat_ipc_kludge ipck; 150 + if (!uptr) 151 + return -EINVAL; 152 + if (copy_from_user(&ipck, uptr, sizeof(ipck))) 153 + return -EFAULT; 154 + return compat_sys_msgrcv(first, ipck.msgp, second, 155 + ipck.msgtyp, third); 156 + } 157 + return compat_sys_msgrcv(first, ptr, second, fifth, third); 158 + } 159 + case MSGGET: 160 + return sys_msgget(first, second); 161 + case MSGCTL: 162 + return compat_sys_msgctl(first, second, compat_ptr(ptr)); 163 + 164 + case SHMAT: { 165 + int err; 166 + unsigned long raddr; 167 + 168 + if (version == 1) 169 + return -EINVAL; 170 + err = do_shmat(first, compat_ptr(ptr), second, &raddr, 171 + COMPAT_SHMLBA); 172 + if (err < 0) 173 + return err; 174 + return put_user(raddr, (compat_ulong_t *)compat_ptr(third)); 175 + } 176 + case SHMDT: 177 + return sys_shmdt(compat_ptr(ptr)); 178 + case SHMGET: 179 + return sys_shmget(first, (unsigned)second, third); 180 + case SHMCTL: 181 + return compat_sys_shmctl(first, second, compat_ptr(ptr)); 182 + } 183 + 184 + return -ENOSYS; 185 + } 186 + #endif 99 187 #endif