summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Brodowski <linux@dominikbrodowski.net>2018-03-20 15:12:33 -0400
committerDominik Brodowski <linux@dominikbrodowski.net>2018-04-02 14:15:25 -0400
commitc84d0791dfa7fe8f051082c09a558eb3e2d01931 (patch)
treeb9164f0e85a7f184e6fdcec92b436e37f660c4d1
parentda1e2744341542e404c172bcf6a321f509408b14 (diff)
ipc: add shmctl syscall/compat_syscall wrappers
Provide ksys_shmctl() and compat_ksys_shmctl() wrappers to avoid in-kernel calls to these syscalls. The ksys_ prefix denotes that these functions are meant as a drop-in replacement for the syscalls. In particular, they use the same calling convention as sys_shmctl() and compat_sys_shmctl(). 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>
-rw-r--r--ipc/shm.c14
-rw-r--r--ipc/syscall.c4
-rw-r--r--ipc/util.h2
3 files changed, 16 insertions, 4 deletions
diff --git a/ipc/shm.c b/ipc/shm.c
index e5838e3328dc..0aae3e55bc56 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -1045,7 +1045,7 @@ out_unlock1:
1045 return err; 1045 return err;
1046} 1046}
1047 1047
1048SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf) 1048long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf)
1049{ 1049{
1050 int err, version; 1050 int err, version;
1051 struct ipc_namespace *ns; 1051 struct ipc_namespace *ns;
@@ -1099,6 +1099,11 @@ SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
1099 } 1099 }
1100} 1100}
1101 1101
1102SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, struct shmid_ds __user *, buf)
1103{
1104 return ksys_shmctl(shmid, cmd, buf);
1105}
1106
1102#ifdef CONFIG_COMPAT 1107#ifdef CONFIG_COMPAT
1103 1108
1104struct compat_shmid_ds { 1109struct compat_shmid_ds {
@@ -1218,7 +1223,7 @@ static int copy_compat_shmid_from_user(struct shmid64_ds *out, void __user *buf,
1218 } 1223 }
1219} 1224}
1220 1225
1221COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr) 1226long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr)
1222{ 1227{
1223 struct ipc_namespace *ns; 1228 struct ipc_namespace *ns;
1224 struct shmid64_ds sem64; 1229 struct shmid64_ds sem64;
@@ -1273,6 +1278,11 @@ COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr)
1273 } 1278 }
1274 return err; 1279 return err;
1275} 1280}
1281
1282COMPAT_SYSCALL_DEFINE3(shmctl, int, shmid, int, cmd, void __user *, uptr)
1283{
1284 return compat_ksys_shmctl(shmid, cmd, uptr);
1285}
1276#endif 1286#endif
1277 1287
1278/* 1288/*
diff --git a/ipc/syscall.c b/ipc/syscall.c
index b3aa71564815..34bbabc9e672 100644
--- a/ipc/syscall.c
+++ b/ipc/syscall.c
@@ -94,7 +94,7 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
94 case SHMGET: 94 case SHMGET:
95 return ksys_shmget(first, second, third); 95 return ksys_shmget(first, second, third);
96 case SHMCTL: 96 case SHMCTL:
97 return sys_shmctl(first, second, 97 return ksys_shmctl(first, second,
98 (struct shmid_ds __user *) ptr); 98 (struct shmid_ds __user *) ptr);
99 default: 99 default:
100 return -ENOSYS; 100 return -ENOSYS;
@@ -182,7 +182,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
182 case SHMGET: 182 case SHMGET:
183 return ksys_shmget(first, (unsigned int)second, third); 183 return ksys_shmget(first, (unsigned int)second, third);
184 case SHMCTL: 184 case SHMCTL:
185 return compat_sys_shmctl(first, second, compat_ptr(ptr)); 185 return compat_ksys_shmctl(first, second, compat_ptr(ptr));
186 } 186 }
187 187
188 return -ENOSYS; 188 return -ENOSYS;
diff --git a/ipc/util.h b/ipc/util.h
index 7770bcad1168..16e8b5b8c416 100644
--- a/ipc/util.h
+++ b/ipc/util.h
@@ -245,6 +245,7 @@ long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg);
245long ksys_msgget(key_t key, int msgflg); 245long ksys_msgget(key_t key, int msgflg);
246long ksys_shmget(key_t key, size_t size, int shmflg); 246long ksys_shmget(key_t key, size_t size, int shmflg);
247long ksys_shmdt(char __user *shmaddr); 247long ksys_shmdt(char __user *shmaddr);
248long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
248 249
249/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */ 250/* for CONFIG_ARCH_WANT_OLD_COMPAT_IPC */
250#ifdef CONFIG_COMPAT 251#ifdef CONFIG_COMPAT
@@ -252,6 +253,7 @@ long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
252 unsigned int nsops, 253 unsigned int nsops,
253 const struct compat_timespec __user *timeout); 254 const struct compat_timespec __user *timeout);
254long compat_ksys_semctl(int semid, int semnum, int cmd, int arg); 255long compat_ksys_semctl(int semid, int semnum, int cmd, int arg);
256long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr);
255#endif /* CONFIG_COMPAT */ 257#endif /* CONFIG_COMPAT */
256 258
257#endif 259#endif