Skip to content

Commit da1e274

Browse files
author
Dominik Brodowski
committed
ipc: add shmdt syscall wrapper
Provide ksys_shmdt() 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_shmdt(). 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 65749e0 commit da1e274

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎ipc/shm.c‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1481,7 +1481,7 @@ COMPAT_SYSCALL_DEFINE3(shmat, int, shmid, compat_uptr_t, shmaddr, int, shmflg)
14811481
* detach and kill segment if marked destroyed.
14821482
* The work is done in shm_close.
14831483
*/
1484-
SYSCALL_DEFINE1(shmdt, char __user *, shmaddr)
1484+
long ksys_shmdt(char __user *shmaddr)
14851485
{
14861486
struct mm_struct *mm = current->mm;
14871487
struct vm_area_struct *vma;
@@ -1588,6 +1588,11 @@ SYSCALL_DEFINE1(shmdt, char __user *, shmaddr)
15881588
return retval;
15891589
}
15901590

1591+
SYSCALL_DEFINE1(shmdt, char __user *, shmaddr)
1592+
{
1593+
return ksys_shmdt(shmaddr);
1594+
}
1595+
15911596
#ifdef CONFIG_PROC_FS
15921597
static int sysvipc_shm_proc_show(struct seq_file *s, void *it)
15931598
{

‎ipc/syscall.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
9090
return -EINVAL;
9191
}
9292
case SHMDT:
93-
return sys_shmdt((char __user *)ptr);
93+
return ksys_shmdt((char __user *)ptr);
9494
case SHMGET:
9595
return ksys_shmget(first, second, third);
9696
case SHMCTL:
@@ -178,7 +178,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
178178
return put_user(raddr, (compat_ulong_t __user *)compat_ptr(third));
179179
}
180180
case SHMDT:
181-
return sys_shmdt(compat_ptr(ptr));
181+
return ksys_shmdt(compat_ptr(ptr));
182182
case SHMGET:
183183
return ksys_shmget(first, (unsigned int)second, third);
184184
case SHMCTL:

‎ipc/util.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ long ksys_semget(key_t key, int nsems, int semflg);
244244
long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg);
245245
long ksys_msgget(key_t key, int msgflg);
246246
long ksys_shmget(key_t key, size_t size, int shmflg);
247+
long ksys_shmdt(char __user *shmaddr);
247248

248249
/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */
249250
#ifdef CONFIG_COMPAT

0 commit comments

Comments
 (0)