aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/Kconfig3
-rw-r--r--arch/mips/Kconfig1
-rw-r--r--arch/powerpc/Kconfig1
-rw-r--r--arch/s390/Kconfig1
-rw-r--r--arch/sparc/Kconfig1
-rw-r--r--arch/tile/include/asm/compat.h11
-rw-r--r--arch/tile/kernel/compat.c43
-rw-r--r--arch/x86/Kconfig1
-rw-r--r--include/asm-generic/unistd.h2
-rw-r--r--include/linux/compat.h12
-rw-r--r--ipc/compat.c70
11 files changed, 84 insertions, 62 deletions
diff --git a/arch/Kconfig b/arch/Kconfig
index a6f14f622d13..684eb5af439d 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -213,4 +213,7 @@ config HAVE_CMPXCHG_LOCAL
213config HAVE_CMPXCHG_DOUBLE 213config HAVE_CMPXCHG_DOUBLE
214 bool 214 bool
215 215
216config ARCH_WANT_OLD_COMPAT_IPC
217 bool
218
216source "kernel/gcov/Kconfig" 219source "kernel/gcov/Kconfig"
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index edbbae17e820..ce30e2f91d77 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2457,6 +2457,7 @@ config MIPS32_COMPAT
2457config COMPAT 2457config COMPAT
2458 bool 2458 bool
2459 depends on MIPS32_COMPAT 2459 depends on MIPS32_COMPAT
2460 select ARCH_WANT_OLD_COMPAT_IPC
2460 default y 2461 default y
2461 2462
2462config SYSVIPC_COMPAT 2463config SYSVIPC_COMPAT
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
index d219ebecabf0..eeaa5328b862 100644
--- a/arch/powerpc/Kconfig
+++ b/arch/powerpc/Kconfig
@@ -154,6 +154,7 @@ config COMPAT
154 bool 154 bool
155 default y if PPC64 155 default y if PPC64
156 select COMPAT_BINFMT_ELF 156 select COMPAT_BINFMT_ELF
157 select ARCH_WANT_OLD_COMPAT_IPC
157 158
158config SYSVIPC_COMPAT 159config SYSVIPC_COMPAT
159 bool 160 bool
diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig
index 465d5be1f0f4..2b7c0fbe578e 100644
--- a/arch/s390/Kconfig
+++ b/arch/s390/Kconfig
@@ -219,6 +219,7 @@ config COMPAT
219 prompt "Kernel support for 31 bit emulation" 219 prompt "Kernel support for 31 bit emulation"
220 depends on 64BIT 220 depends on 64BIT
221 select COMPAT_BINFMT_ELF 221 select COMPAT_BINFMT_ELF
222 select ARCH_WANT_OLD_COMPAT_IPC
222 help 223 help
223 Select this option if you want to enable your system kernel to 224 Select this option if you want to enable your system kernel to
224 handle system-calls from ELF binaries for 31 bit ESA. This option 225 handle system-calls from ELF binaries for 31 bit ESA. This option
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index 1666de84d477..6c0683d3fcba 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -577,6 +577,7 @@ config COMPAT
577 depends on SPARC64 577 depends on SPARC64
578 default y 578 default y
579 select COMPAT_BINFMT_ELF 579 select COMPAT_BINFMT_ELF
580 select ARCH_WANT_OLD_COMPAT_IPC
580 581
581config SYSVIPC_COMPAT 582config SYSVIPC_COMPAT
582 bool 583 bool
diff --git a/arch/tile/include/asm/compat.h b/arch/tile/include/asm/compat.h
index bf95f55b82b0..4b4b28969a65 100644
--- a/arch/tile/include/asm/compat.h
+++ b/arch/tile/include/asm/compat.h
@@ -242,17 +242,6 @@ long compat_sys_fallocate(int fd, int mode,
242long compat_sys_sched_rr_get_interval(compat_pid_t pid, 242long compat_sys_sched_rr_get_interval(compat_pid_t pid,
243 struct compat_timespec __user *interval); 243 struct compat_timespec __user *interval);
244 244
245/* Versions of compat functions that differ from generic Linux. */
246struct compat_msgbuf;
247long tile_compat_sys_msgsnd(int msqid,
248 struct compat_msgbuf __user *msgp,
249 size_t msgsz, int msgflg);
250long tile_compat_sys_msgrcv(int msqid,
251 struct compat_msgbuf __user *msgp,
252 size_t msgsz, long msgtyp, int msgflg);
253long tile_compat_sys_ptrace(compat_long_t request, compat_long_t pid,
254 compat_long_t addr, compat_long_t data);
255
256/* Tilera Linux syscalls that don't have "compat" versions. */ 245/* Tilera Linux syscalls that don't have "compat" versions. */
257#define compat_sys_flush_cache sys_flush_cache 246#define compat_sys_flush_cache sys_flush_cache
258 247
diff --git a/arch/tile/kernel/compat.c b/arch/tile/kernel/compat.c
index bf5e9d70266c..d67459b9ac2a 100644
--- a/arch/tile/kernel/compat.c
+++ b/arch/tile/kernel/compat.c
@@ -16,7 +16,6 @@
16#define __SYSCALL_COMPAT 16#define __SYSCALL_COMPAT
17 17
18#include <linux/compat.h> 18#include <linux/compat.h>
19#include <linux/msg.h>
20#include <linux/syscalls.h> 19#include <linux/syscalls.h>
21#include <linux/kdev_t.h> 20#include <linux/kdev_t.h>
22#include <linux/fs.h> 21#include <linux/fs.h>
@@ -95,52 +94,10 @@ long compat_sys_sched_rr_get_interval(compat_pid_t pid,
95 return ret; 94 return ret;
96} 95}
97 96
98/*
99 * The usual compat_sys_msgsnd() and _msgrcv() seem to be assuming
100 * some different calling convention than our normal 32-bit tile code.
101 */
102
103/* Already defined in ipc/compat.c, but we need it here. */
104struct compat_msgbuf {
105 compat_long_t mtype;
106 char mtext[1];
107};
108
109long tile_compat_sys_msgsnd(int msqid,
110 struct compat_msgbuf __user *msgp,
111 size_t msgsz, int msgflg)
112{
113 compat_long_t mtype;
114
115 if (get_user(mtype, &msgp->mtype))
116 return -EFAULT;
117 return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
118}
119
120long tile_compat_sys_msgrcv(int msqid,
121 struct compat_msgbuf __user *msgp,
122 size_t msgsz, long msgtyp, int msgflg)
123{
124 long err, mtype;
125
126 err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg);
127 if (err < 0)
128 goto out;
129
130 if (put_user(mtype, &msgp->mtype))
131 err = -EFAULT;
132 out:
133 return err;
134}
135
136/* Provide the compat syscall number to call mapping. */ 97/* Provide the compat syscall number to call mapping. */
137#undef __SYSCALL 98#undef __SYSCALL
138#define __SYSCALL(nr, call) [nr] = (call), 99#define __SYSCALL(nr, call) [nr] = (call),
139 100
140/* The generic versions of these don't work for Tile. */
141#define compat_sys_msgrcv tile_compat_sys_msgrcv
142#define compat_sys_msgsnd tile_compat_sys_msgsnd
143
144/* See comments in sys.c */ 101/* See comments in sys.c */
145#define compat_sys_fadvise64_64 sys32_fadvise64_64 102#define compat_sys_fadvise64_64 sys32_fadvise64_64
146#define compat_sys_readahead sys32_readahead 103#define compat_sys_readahead sys32_readahead
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 3ad653de7100..e3974694078b 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2177,6 +2177,7 @@ config IA32_AOUT
2177config COMPAT 2177config COMPAT
2178 def_bool y 2178 def_bool y
2179 depends on IA32_EMULATION 2179 depends on IA32_EMULATION
2180 select ARCH_WANT_OLD_COMPAT_IPC
2180 2181
2181config COMPAT_FOR_U64_ALIGNMENT 2182config COMPAT_FOR_U64_ALIGNMENT
2182 def_bool COMPAT 2183 def_bool COMPAT
diff --git a/include/asm-generic/unistd.h b/include/asm-generic/unistd.h
index 2292d1af9d70..991ef01cd77e 100644
--- a/include/asm-generic/unistd.h
+++ b/include/asm-generic/unistd.h
@@ -218,7 +218,7 @@ __SC_COMP(__NR_pwritev, sys_pwritev, compat_sys_pwritev)
218 218
219/* fs/sendfile.c */ 219/* fs/sendfile.c */
220#define __NR3264_sendfile 71 220#define __NR3264_sendfile 71
221__SC_3264(__NR3264_sendfile, sys_sendfile64, sys_sendfile) 221__SYSCALL(__NR3264_sendfile, sys_sendfile64)
222 222
223/* fs/select.c */ 223/* fs/select.c */
224#define __NR_pselect6 72 224#define __NR_pselect6 72
diff --git a/include/linux/compat.h b/include/linux/compat.h
index 7e05fcee75a1..35c2dbf2448a 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -224,6 +224,7 @@ struct compat_sysinfo;
224struct compat_sysctl_args; 224struct compat_sysctl_args;
225struct compat_kexec_segment; 225struct compat_kexec_segment;
226struct compat_mq_attr; 226struct compat_mq_attr;
227struct compat_msgbuf;
227 228
228extern void compat_exit_robust_list(struct task_struct *curr); 229extern void compat_exit_robust_list(struct task_struct *curr);
229 230
@@ -234,13 +235,22 @@ asmlinkage long
234compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, 235compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
235 compat_size_t __user *len_ptr); 236 compat_size_t __user *len_ptr);
236 237
238#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
237long compat_sys_semctl(int first, int second, int third, void __user *uptr); 239long compat_sys_semctl(int first, int second, int third, void __user *uptr);
238long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); 240long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
239long compat_sys_msgrcv(int first, int second, int msgtyp, int third, 241long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
240 int version, void __user *uptr); 242 int version, void __user *uptr);
241long compat_sys_msgctl(int first, int second, void __user *uptr);
242long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, 243long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
243 void __user *uptr); 244 void __user *uptr);
245#else
246long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
247long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
248 size_t msgsz, int msgflg);
249long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
250 size_t msgsz, long msgtyp, int msgflg);
251long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
252#endif
253long compat_sys_msgctl(int first, int second, void __user *uptr);
244long compat_sys_shmctl(int first, int second, void __user *uptr); 254long compat_sys_shmctl(int first, int second, void __user *uptr);
245long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, 255long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
246 unsigned nsems, const struct compat_timespec __user *timeout); 256 unsigned nsems, const struct compat_timespec __user *timeout);
diff --git a/ipc/compat.c b/ipc/compat.c
index 845a28738d3a..a6df704f521e 100644
--- a/ipc/compat.c
+++ b/ipc/compat.c
@@ -27,6 +27,7 @@
27#include <linux/msg.h> 27#include <linux/msg.h>
28#include <linux/shm.h> 28#include <linux/shm.h>
29#include <linux/syscalls.h> 29#include <linux/syscalls.h>
30#include <linux/ptrace.h>
30 31
31#include <linux/mutex.h> 32#include <linux/mutex.h>
32#include <asm/uaccess.h> 33#include <asm/uaccess.h>
@@ -117,6 +118,7 @@ extern int sem_ctls[];
117 118
118static inline int compat_ipc_parse_version(int *cmd) 119static inline int compat_ipc_parse_version(int *cmd)
119{ 120{
121#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
120 int version = *cmd & IPC_64; 122 int version = *cmd & IPC_64;
121 123
122 /* this is tricky: architectures that have support for the old 124 /* this is tricky: architectures that have support for the old
@@ -128,6 +130,10 @@ static inline int compat_ipc_parse_version(int *cmd)
128 *cmd &= ~IPC_64; 130 *cmd &= ~IPC_64;
129#endif 131#endif
130 return version; 132 return version;
133#else
134 /* With the asm-generic APIs, we always use the 64-bit versions. */
135 return IPC_64;
136#endif
131} 137}
132 138
133static inline int __get_compat_ipc64_perm(struct ipc64_perm *p64, 139static inline int __get_compat_ipc64_perm(struct ipc64_perm *p64,
@@ -232,10 +238,9 @@ static inline int put_compat_semid_ds(struct semid64_ds *s,
232 return err; 238 return err;
233} 239}
234 240
235long compat_sys_semctl(int first, int second, int third, void __user *uptr) 241static long do_compat_semctl(int first, int second, int third, u32 pad)
236{ 242{
237 union semun fourth; 243 union semun fourth;
238 u32 pad;
239 int err, err2; 244 int err, err2;
240 struct semid64_ds s64; 245 struct semid64_ds s64;
241 struct semid64_ds __user *up64; 246 struct semid64_ds __user *up64;
@@ -243,10 +248,6 @@ long compat_sys_semctl(int first, int second, int third, void __user *uptr)
243 248
244 memset(&s64, 0, sizeof(s64)); 249 memset(&s64, 0, sizeof(s64));
245 250
246 if (!uptr)
247 return -EINVAL;
248 if (get_user(pad, (u32 __user *) uptr))
249 return -EFAULT;
250 if ((third & (~IPC_64)) == SETVAL) 251 if ((third & (~IPC_64)) == SETVAL)
251 fourth.val = (int) pad; 252 fourth.val = (int) pad;
252 else 253 else
@@ -305,6 +306,18 @@ long compat_sys_semctl(int first, int second, int third, void __user *uptr)
305 return err; 306 return err;
306} 307}
307 308
309#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
310long compat_sys_semctl(int first, int second, int third, void __user *uptr)
311{
312 u32 pad;
313
314 if (!uptr)
315 return -EINVAL;
316 if (get_user(pad, (u32 __user *) uptr))
317 return -EFAULT;
318 return do_compat_semctl(first, second, third, pad);
319}
320
308long compat_sys_msgsnd(int first, int second, int third, void __user *uptr) 321long compat_sys_msgsnd(int first, int second, int third, void __user *uptr)
309{ 322{
310 struct compat_msgbuf __user *up = uptr; 323 struct compat_msgbuf __user *up = uptr;
@@ -353,6 +366,37 @@ long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
353out: 366out:
354 return err; 367 return err;
355} 368}
369#else
370long compat_sys_semctl(int semid, int semnum, int cmd, int arg)
371{
372 return do_compat_semctl(semid, semnum, cmd, arg);
373}
374
375long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp,
376 size_t msgsz, int msgflg)
377{
378 compat_long_t mtype;
379
380 if (get_user(mtype, &msgp->mtype))
381 return -EFAULT;
382 return do_msgsnd(msqid, mtype, msgp->mtext, msgsz, msgflg);
383}
384
385long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp,
386 size_t msgsz, long msgtyp, int msgflg)
387{
388 long err, mtype;
389
390 err = do_msgrcv(msqid, &mtype, msgp->mtext, msgsz, msgtyp, msgflg);
391 if (err < 0)
392 goto out;
393
394 if (put_user(mtype, &msgp->mtype))
395 err = -EFAULT;
396 out:
397 return err;
398}
399#endif
356 400
357static inline int get_compat_msqid64(struct msqid64_ds *m64, 401static inline int get_compat_msqid64(struct msqid64_ds *m64,
358 struct compat_msqid64_ds __user *up64) 402 struct compat_msqid64_ds __user *up64)
@@ -470,6 +514,7 @@ long compat_sys_msgctl(int first, int second, void __user *uptr)
470 return err; 514 return err;
471} 515}
472 516
517#ifdef CONFIG_ARCH_WANT_OLD_COMPAT_IPC
473long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, 518long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
474 void __user *uptr) 519 void __user *uptr)
475{ 520{
@@ -485,6 +530,19 @@ long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
485 uaddr = compat_ptr(third); 530 uaddr = compat_ptr(third);
486 return put_user(raddr, uaddr); 531 return put_user(raddr, uaddr);
487} 532}
533#else
534long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg)
535{
536 unsigned long ret;
537 long err;
538
539 err = do_shmat(shmid, compat_ptr(shmaddr), shmflg, &ret);
540 if (err)
541 return err;
542 force_successful_syscall_return();
543 return (long)ret;
544}
545#endif
488 546
489static inline int get_compat_shmid64_ds(struct shmid64_ds *s64, 547static inline int get_compat_shmid64_ds(struct shmid64_ds *s64,
490 struct compat_shmid64_ds __user *up64) 548 struct compat_shmid64_ds __user *up64)