Commit 76a9bdec authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] generic 32 bit emulation for System-V IPC

From: Arnd Bergmann <arnd@arndb.de>

Adds a generic implementation of 32 bit emulation for IPC system calls.  The
code is based on the existing implementations for sparc64, ia64, mips, s390,
ppc and x86_64, which can subsequently be converted to use this.
parent 5299b8f7
...@@ -537,7 +537,11 @@ config DEBUG_INFO ...@@ -537,7 +537,11 @@ config DEBUG_INFO
debugging info resulting in a larger kernel image. debugging info resulting in a larger kernel image.
Say Y here only if you plan to use gdb to debug the kernel. Say Y here only if you plan to use gdb to debug the kernel.
If you don't debug the kernel, you can say N. If you don't debug the kernel, you can say N.
config SYSVIPC_COMPAT
bool
depends on COMPAT && SYSVIPC
default y
endmenu endmenu
source "security/Kconfig" source "security/Kconfig"
......
This diff is collapsed.
...@@ -143,6 +143,11 @@ config COMPAT ...@@ -143,6 +143,11 @@ config COMPAT
depends on S390_SUPPORT depends on S390_SUPPORT
default y default y
config SYSVIPC_COMPAT
bool
depends on COMPAT && SYSVIPC
default y
config BINFMT_ELF32 config BINFMT_ELF32
tristate "Kernel support for 31 bit ELF binaries" tristate "Kernel support for 31 bit ELF binaries"
depends on S390_SUPPORT depends on S390_SUPPORT
......
This diff is collapsed.
...@@ -387,6 +387,10 @@ config COMPAT ...@@ -387,6 +387,10 @@ config COMPAT
depends on IA32_EMULATION depends on IA32_EMULATION
default y default y
config SYSVIPC_COMPAT
bool
depends on COMPAT && SYSVIPC
default y
config UID16 config UID16
bool bool
......
This diff is collapsed.
...@@ -11,6 +11,7 @@ typedef u32 compat_size_t; ...@@ -11,6 +11,7 @@ typedef u32 compat_size_t;
typedef s32 compat_ssize_t; typedef s32 compat_ssize_t;
typedef s32 compat_time_t; typedef s32 compat_time_t;
typedef s32 compat_clock_t; typedef s32 compat_clock_t;
typedef s32 compat_key_t;
typedef s32 compat_pid_t; typedef s32 compat_pid_t;
typedef u16 compat_uid_t; typedef u16 compat_uid_t;
typedef u16 compat_gid_t; typedef u16 compat_gid_t;
...@@ -116,6 +117,64 @@ typedef u32 compat_sigset_word; ...@@ -116,6 +117,64 @@ typedef u32 compat_sigset_word;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL #define COMPAT_LOFF_T_MAX 0x7fffffffffffffffL
struct compat_ipc64_perm {
compat_key_t key;
compat_uid32_t uid;
compat_gid32_t gid;
compat_uid32_t cuid;
compat_gid32_t cgid;
unsigned short mode;
unsigned short __pad1;
unsigned short seq;
unsigned short __pad2;
compat_ulong_t unused1;
compat_ulong_t unused2;
};
struct compat_semid64_ds {
struct compat_ipc64_perm sem_perm;
compat_time_t sem_otime;
compat_ulong_t __unused1;
compat_time_t sem_ctime;
compat_ulong_t __unused2;
compat_ulong_t sem_nsems;
compat_ulong_t __unused3;
compat_ulong_t __unused4;
};
struct compat_msqid64_ds {
struct compat_ipc64_perm msg_perm;
compat_time_t msg_stime;
compat_ulong_t __unused1;
compat_time_t msg_rtime;
compat_ulong_t __unused2;
compat_time_t msg_ctime;
compat_ulong_t __unused3;
compat_ulong_t msg_cbytes;
compat_ulong_t msg_qnum;
compat_ulong_t msg_qbytes;
compat_pid_t msg_lspid;
compat_pid_t msg_lrpid;
compat_ulong_t __unused4;
compat_ulong_t __unused5;
};
struct compat_shmid64_ds {
struct compat_ipc64_perm shm_perm;
compat_size_t shm_segsz;
compat_time_t shm_atime;
compat_ulong_t __unused1;
compat_time_t shm_dtime;
compat_ulong_t __unused2;
compat_time_t shm_ctime;
compat_ulong_t __unused3;
compat_pid_t shm_cpid;
compat_pid_t shm_lpid;
compat_ulong_t shm_nattch;
compat_ulong_t __unused4;
compat_ulong_t __unused5;
};
/* /*
* A pointer passed in from user mode. This should not be used for syscall parameters, * A pointer passed in from user mode. This should not be used for syscall parameters,
* just declare them as pointers because the syscall entry code will have appropriately * just declare them as pointers because the syscall entry code will have appropriately
......
...@@ -15,6 +15,8 @@ typedef s32 compat_clock_t; ...@@ -15,6 +15,8 @@ typedef s32 compat_clock_t;
typedef s32 compat_pid_t; typedef s32 compat_pid_t;
typedef u16 compat_uid_t; typedef u16 compat_uid_t;
typedef u16 compat_gid_t; typedef u16 compat_gid_t;
typedef u32 compat_uid32_t;
typedef u32 compat_gid32_t;
typedef u16 compat_mode_t; typedef u16 compat_mode_t;
typedef u32 compat_ino_t; typedef u32 compat_ino_t;
typedef u16 compat_dev_t; typedef u16 compat_dev_t;
...@@ -25,6 +27,7 @@ typedef u16 compat_ipc_pid_t; ...@@ -25,6 +27,7 @@ typedef u16 compat_ipc_pid_t;
typedef s32 compat_daddr_t; typedef s32 compat_daddr_t;
typedef u32 compat_caddr_t; typedef u32 compat_caddr_t;
typedef __kernel_fsid_t compat_fsid_t; typedef __kernel_fsid_t compat_fsid_t;
typedef s32 compat_key_t;
typedef s32 compat_timer_t; typedef s32 compat_timer_t;
typedef s32 compat_int_t; typedef s32 compat_int_t;
...@@ -135,4 +138,61 @@ static inline void *compat_alloc_user_space(long len) ...@@ -135,4 +138,61 @@ static inline void *compat_alloc_user_space(long len)
return (void *) (stack - len); return (void *) (stack - len);
} }
struct compat_ipc64_perm {
compat_key_t key;
compat_uid32_t uid;
compat_gid32_t gid;
compat_uid32_t cuid;
compat_gid32_t cgid;
compat_mode_t mode;
unsigned short __pad1;
unsigned short seq;
unsigned short __pad2;
unsigned int __unused1;
unsigned int __unused2;
};
struct compat_semid64_ds {
struct compat_ipc64_perm sem_perm;
compat_time_t sem_otime;
compat_ulong_t __pad1;
compat_time_t sem_ctime;
compat_ulong_t __pad2;
compat_ulong_t sem_nsems;
compat_ulong_t __unused1;
compat_ulong_t __unused2;
};
struct compat_msqid64_ds {
struct compat_ipc64_perm msg_perm;
compat_time_t msg_stime;
compat_ulong_t __pad1;
compat_time_t msg_rtime;
compat_ulong_t __pad2;
compat_time_t msg_ctime;
compat_ulong_t __pad3;
compat_ulong_t msg_cbytes;
compat_ulong_t msg_qnum;
compat_ulong_t msg_qbytes;
compat_pid_t msg_lspid;
compat_pid_t msg_lrpid;
compat_ulong_t __unused1;
compat_ulong_t __unused2;
};
struct compat_shmid64_ds {
struct compat_ipc64_perm shm_perm;
compat_size_t shm_segsz;
compat_time_t shm_atime;
compat_ulong_t __pad1;
compat_time_t shm_dtime;
compat_ulong_t __pad2;
compat_time_t shm_ctime;
compat_ulong_t __pad3;
compat_pid_t shm_cpid;
compat_pid_t shm_lpid;
compat_ulong_t shm_nattch;
compat_ulong_t __unused1;
compat_ulong_t __unused2;
};
#endif /* _ASM_S390X_COMPAT_H */ #endif /* _ASM_S390X_COMPAT_H */
...@@ -29,6 +29,7 @@ typedef s32 compat_daddr_t; ...@@ -29,6 +29,7 @@ typedef s32 compat_daddr_t;
typedef u32 compat_caddr_t; typedef u32 compat_caddr_t;
typedef __kernel_fsid_t compat_fsid_t; typedef __kernel_fsid_t compat_fsid_t;
typedef u32 compat_timer_t; typedef u32 compat_timer_t;
typedef s32 compat_key_t;
typedef s32 compat_int_t; typedef s32 compat_int_t;
typedef s32 compat_long_t; typedef s32 compat_long_t;
...@@ -119,6 +120,64 @@ typedef u32 compat_sigset_word; ...@@ -119,6 +120,64 @@ typedef u32 compat_sigset_word;
#define COMPAT_OFF_T_MAX 0x7fffffff #define COMPAT_OFF_T_MAX 0x7fffffff
#define COMPAT_LOFF_T_MAX 0x7fffffffffffffff #define COMPAT_LOFF_T_MAX 0x7fffffffffffffff
struct compat_ipc64_perm {
compat_key_t key;
compat_uid32_t uid;
compat_gid32_t gid;
compat_uid32_t cuid;
compat_gid32_t cgid;
unsigned short mode;
unsigned short __pad1;
unsigned short seq;
unsigned short __pad2;
compat_ulong_t unused1;
compat_ulong_t unused2;
};
struct compat_semid64_ds {
struct compat_ipc64_perm sem_perm;
compat_time_t sem_otime;
compat_ulong_t __unused1;
compat_time_t sem_ctime;
compat_ulong_t __unused2;
compat_ulong_t sem_nsems;
compat_ulong_t __unused3;
compat_ulong_t __unused4;
};
struct compat_msqid64_ds {
struct compat_ipc64_perm msg_perm;
compat_time_t msg_stime;
compat_ulong_t __unused1;
compat_time_t msg_rtime;
compat_ulong_t __unused2;
compat_time_t msg_ctime;
compat_ulong_t __unused3;
compat_ulong_t msg_cbytes;
compat_ulong_t msg_qnum;
compat_ulong_t msg_qbytes;
compat_pid_t msg_lspid;
compat_pid_t msg_lrpid;
compat_ulong_t __unused4;
compat_ulong_t __unused5;
};
struct compat_shmid64_ds {
struct compat_ipc64_perm shm_perm;
compat_size_t shm_segsz;
compat_time_t shm_atime;
compat_ulong_t __unused1;
compat_time_t shm_dtime;
compat_ulong_t __unused2;
compat_time_t shm_ctime;
compat_ulong_t __unused3;
compat_pid_t shm_cpid;
compat_pid_t shm_lpid;
compat_ulong_t shm_nattch;
compat_ulong_t __unused4;
compat_ulong_t __unused5;
};
/* /*
* A pointer passed in from user mode. This should not * A pointer passed in from user mode. This should not
* be used for syscall parameters, just declare them * be used for syscall parameters, just declare them
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <linux/stat.h> #include <linux/stat.h>
#include <linux/param.h> /* for HZ */ #include <linux/param.h> /* for HZ */
#include <linux/sem.h>
#include <asm/compat.h> #include <asm/compat.h>
#define compat_jiffies_to_clock_t(x) \ #define compat_jiffies_to_clock_t(x) \
...@@ -88,5 +90,15 @@ typedef union compat_sigval { ...@@ -88,5 +90,15 @@ typedef union compat_sigval {
compat_uptr_t sival_ptr; compat_uptr_t sival_ptr;
} compat_sigval_t; } compat_sigval_t;
long compat_sys_semctl(int first, int second, int third, void __user *uptr);
long compat_sys_msgsnd(int first, int second, int third, void __user *uptr);
long compat_sys_msgrcv(int first, int second, int msgtyp, int third,
int version, void __user *uptr);
long compat_sys_msgctl(int first, int second, void __user *uptr);
long compat_sys_shmat(int first, int second, compat_uptr_t third, int version,
void __user *uptr);
long compat_sys_shmctl(int first, int second, void __user *uptr);
long compat_sys_semtimedop(int semid, struct sembuf __user *tsems,
unsigned nsems, const struct compat_timespec __user *timeout);
#endif /* CONFIG_COMPAT */ #endif /* CONFIG_COMPAT */
#endif /* _LINUX_COMPAT_H */ #endif /* _LINUX_COMPAT_H */
...@@ -4,4 +4,5 @@ ...@@ -4,4 +4,5 @@
obj-y := util.o obj-y := util.o
obj-$(CONFIG_SYSVIPC_COMPAT) += compat.o
obj-$(CONFIG_SYSVIPC) += msg.o sem.o shm.o obj-$(CONFIG_SYSVIPC) += msg.o sem.o shm.o
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment