Skip to content

Commit 6989471

Browse files
author
Dominik Brodowski
committed
ipc: add semget syscall wrapper
Provide ksys_semget() wrapper to avoid in-kernel calls to this syscall. The ksys_ prefix denotes that this function is meant as a drop-in replacement for the syscall. In particular, it uses the same calling convention as sys_semget(). This patch is part of a series which removes in-kernel calls to syscalls. On this basis, the syscall entry path can be streamlined. For details, see http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
1 parent 41f4f0e commit 6989471

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎ipc/sem.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
556556
return 0;
557557
}
558558

559-
SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
559+
long ksys_semget(key_t key, int nsems, int semflg)
560560
{
561561
struct ipc_namespace *ns;
562562
static const struct ipc_ops sem_ops = {
@@ -578,6 +578,11 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
578578
return ipcget(ns, &sem_ids(ns), &sem_ops, &sem_params);
579579
}
580580

581+
SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
582+
{
583+
return ksys_semget(key, nsems, semflg);
584+
}
585+
581586
/**
582587
* perform_atomic_semop[_slow] - Attempt to perform semaphore
583588
* operations on a given array.

‎ipc/syscall.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
3535
(const struct timespec __user *)fifth);
3636

3737
case SEMGET:
38-
return sys_semget(first, second, third);
38+
return ksys_semget(first, second, third);
3939
case SEMCTL: {
4040
unsigned long arg;
4141
if (!ptr)
@@ -132,7 +132,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
132132
return compat_ksys_semtimedop(first, compat_ptr(ptr), second,
133133
compat_ptr(fifth));
134134
case SEMGET:
135-
return sys_semget(first, second, third);
135+
return ksys_semget(first, second, third);
136136
case SEMCTL:
137137
if (!ptr)
138138
return -EINVAL;

‎ipc/util.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ static inline int compat_ipc_parse_version(int *cmd)
240240
long ksys_semtimedop(int semid, struct sembuf __user *tsops,
241241
unsigned int nsops,
242242
const struct timespec __user *timeout);
243+
long ksys_semget(key_t key, int nsems, int semflg);
243244

244245
/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */
245246
#ifdef CONFIG_COMPAT

0 commit comments

Comments
 (0)