diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2012-03-15 13:13:38 -0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2012-03-15 13:13:38 -0400 |
commit | 48b25c43e6eebb6c0edf72935e8720385beca76b (patch) | |
tree | d1c774a79ef5a8373b093479c3dabe9bf16aec07 /include | |
parent | fde7d9049e55ab85a390be7f415d74c9f62dd0f9 (diff) |
[PATCH v3] ipc: provide generic compat versions of IPC syscalls
When using the "compat" APIs, architectures will generally want to
be able to make direct syscalls to msgsnd(), shmctl(), etc., and
in the kernel we would want them to be handled directly by
compat_sys_xxx() functions, as is true for other compat syscalls.
However, for historical reasons, several of the existing compat IPC
syscalls do not do this. semctl() expects a pointer to the fourth
argument, instead of the fourth argument itself. msgsnd(), msgrcv()
and shmat() expect arguments in different order.
This change adds an ARCH_WANT_OLD_COMPAT_IPC config option that can be
set to preserve this behavior for ports that use it (x86, sparc, powerpc,
s390, and mips). No actual semantics are changed for those architectures,
and there is only a minimal amount of code refactoring in ipc/compat.c.
Newer architectures like tile (and perhaps future architectures such
as arm64 and unicore64) should not select this option, and thus can
avoid having any IPC-specific code at all in their architecture-specific
compat layer. In the same vein, if this option is not selected, IPC_64
mode is assumed, since that's what the <asm-generic> headers expect.
The workaround code in "tile" for msgsnd() and msgrcv() is removed
with this change; it also fixes the bug that shmat() and semctl() were
not being properly handled.
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/compat.h | 12 |
1 files changed, 11 insertions, 1 deletions
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; | |||
224 | struct compat_sysctl_args; | 224 | struct compat_sysctl_args; |
225 | struct compat_kexec_segment; | 225 | struct compat_kexec_segment; |
226 | struct compat_mq_attr; | 226 | struct compat_mq_attr; |
227 | struct compat_msgbuf; | ||
227 | 228 | ||
228 | extern void compat_exit_robust_list(struct task_struct *curr); | 229 | extern void compat_exit_robust_list(struct task_struct *curr); |
229 | 230 | ||
@@ -234,13 +235,22 @@ asmlinkage long | |||
234 | compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr, | 235 | compat_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 | ||
237 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); | 239 | long compat_sys_semctl(int first, int second, int third, void __user *uptr); |
238 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); | 240 | long compat_sys_msgsnd(int first, int second, int third, void __user *uptr); |
239 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, | 241 | long compat_sys_msgrcv(int first, int second, int msgtyp, int third, |
240 | int version, void __user *uptr); | 242 | int version, void __user *uptr); |
241 | long compat_sys_msgctl(int first, int second, void __user *uptr); | ||
242 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, | 243 | long compat_sys_shmat(int first, int second, compat_uptr_t third, int version, |
243 | void __user *uptr); | 244 | void __user *uptr); |
245 | #else | ||
246 | long compat_sys_semctl(int semid, int semnum, int cmd, int arg); | ||
247 | long compat_sys_msgsnd(int msqid, struct compat_msgbuf __user *msgp, | ||
248 | size_t msgsz, int msgflg); | ||
249 | long compat_sys_msgrcv(int msqid, struct compat_msgbuf __user *msgp, | ||
250 | size_t msgsz, long msgtyp, int msgflg); | ||
251 | long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg); | ||
252 | #endif | ||
253 | long compat_sys_msgctl(int first, int second, void __user *uptr); | ||
244 | long compat_sys_shmctl(int first, int second, void __user *uptr); | 254 | long compat_sys_shmctl(int first, int second, void __user *uptr); |
245 | long compat_sys_semtimedop(int semid, struct sembuf __user *tsems, | 255 | long 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); |