ipc: rename old-style shmctl/semctl/msgctl syscalls
The behavior of these system calls is slightly different between architectures, as determined by the CONFIG_ARCH_WANT_IPC_PARSE_VERSION symbol. Most architectures that implement the split IPC syscalls don't set that symbol and only get the modern version, but alpha, arm, microblaze, mips-n32, mips-n64 and xtensa expect the caller to pass the IPC_64 flag. For the architectures that so far only implement sys_ipc(), i.e. m68k, mips-o32, powerpc, s390, sh, sparc, and x86-32, we want the new behavior when adding the split syscalls, so we need to distinguish between the two groups of architectures. The method I picked for this distinction is to have a separate system call entry point: sys_old_*ctl() now uses ipc_parse_version, while sys_*ctl() does not. The system call tables of the five architectures are changed accordingly. As an additional benefit, we no longer need the configuration specific definition for ipc_parse_version(), it always does the same thing now, but simply won't get called on architectures with the modern interface. A small downside is that on architectures that do set ARCH_WANT_IPC_PARSE_VERSION, we now have an extra set of entry points that are never called. They only add a few bytes of bloat, so it seems better to keep them compared to adding yet another Kconfig symbol. I considered adding new syscall numbers for the IPC_64 variants for consistency, but decided against that for now. Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
40
ipc/shm.c
40
ipc/shm.c
@@ -1137,16 +1137,15 @@ out_unlock1:
|
||||
return err;
|
||||
}
|
||||
|
||||
long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
|
||||
static long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf, int version)
|
||||
{
|
||||
int err, version;
|
||||
int err;
|
||||
struct ipc_namespace *ns;
|
||||
struct shmid64_ds sem64;
|
||||
|
||||
if (cmd < 0 || shmid < 0)
|
||||
return -EINVAL;
|
||||
|
||||
version = ipc_parse_version(&cmd);
|
||||
ns = current->nsproxy->ipc_ns;
|
||||
|
||||
switch (cmd) {
|
||||
@@ -1194,9 +1193,23 @@ long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
|
||||
|
||||
SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
|
||||
{
|
||||
return ksys_shmctl(shmid, cmd, buf);
|
||||
return ksys_shmctl(shmid, cmd, buf, IPC_64);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_WANT_IPC_PARSE_VERSION
|
||||
long ksys_old_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
|
||||
{
|
||||
int version = ipc_parse_version(&cmd);
|
||||
|
||||
return ksys_shmctl(shmid, cmd, buf, version);
|
||||
}
|
||||
|
||||
SYSCALL_DEFINE3(old_shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
|
||||
{
|
||||
return ksys_old_shmctl(shmid, cmd, buf);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_COMPAT
|
||||
|
||||
struct compat_shmid_ds {
|
||||
@@ -1319,11 +1332,10 @@ static int copy_compat_shmid_from_user(struct shmid64_ds *out, void __user *buf,
|
||||
}
|
||||
}
|
||||
|
||||
long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr)
|
||||
long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr, int version)
|
||||
{
|
||||
struct ipc_namespace *ns;
|
||||
struct shmid64_ds sem64;
|
||||
int version = compat_ipc_parse_version(&cmd);
|
||||
int err;
|
||||
|
||||
ns = current->nsproxy->ipc_ns;
|
||||
@@ -1378,8 +1390,22 @@ long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr)
|
||||
|
||||
COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr)
|
||||
{
|
||||
return compat_ksys_shmctl(shmid, cmd, uptr);
|
||||
return compat_ksys_shmctl(shmid, cmd, uptr, IPC_64);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_ARCH_WANT_COMPAT_IPC_PARSE_VERSION
|
||||
long compat_ksys_old_shmctl(int shmid, int cmd, void __user *uptr)
|
||||
{
|
||||
int version = compat_ipc_parse_version(&cmd);
|
||||
|
||||
return compat_ksys_shmctl(shmid, cmd, uptr, version);
|
||||
}
|
||||
|
||||
COMPAT_SYSCALL_DEFINE3(old_shmctl, int, shmid, int, cmd, void __user *, uptr)
|
||||
{
|
||||
return compat_ksys_old_shmctl(shmid, cmd, uptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user