]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
ipc: add msgctl syscall/compat_syscall wrappers
authorDominik Brodowski <linux@dominikbrodowski.net>
Tue, 20 Mar 2018 19:15:28 +0000 (20:15 +0100)
committerDominik Brodowski <linux@dominikbrodowski.net>
Mon, 2 Apr 2018 18:15:26 +0000 (20:15 +0200)
Provide ksys_msgctl() and compat_ksys_msgctl() 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_msgctl() and compat_sys_msgctl().

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>
ipc/msg.c
ipc/syscall.c
ipc/util.h

index 64e8276be1647c31b4d8e007aae5f929d62bde45..5b026868df0705313137607b3856c3663259ab22 100644 (file)
--- a/ipc/msg.c
+++ b/ipc/msg.c
@@ -538,7 +538,7 @@ out_unlock:
        return err;
 }
 
-SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf)
+long ksys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf)
 {
        int version;
        struct ipc_namespace *ns;
@@ -581,6 +581,11 @@ SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf)
        }
 }
 
+SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, struct msqid_ds __user *, buf)
+{
+       return ksys_msgctl(msqid, cmd, buf);
+}
+
 #ifdef CONFIG_COMPAT
 
 struct compat_msqid_ds {
@@ -651,7 +656,7 @@ static int copy_compat_msqid_to_user(void __user *buf, struct msqid64_ds *in,
        }
 }
 
-COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr)
+long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr)
 {
        struct ipc_namespace *ns;
        int err;
@@ -692,6 +697,11 @@ COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr)
                return -EINVAL;
        }
 }
+
+COMPAT_SYSCALL_DEFINE3(msgctl, int, msqid, int, cmd, void __user *, uptr)
+{
+       return compat_ksys_msgctl(msqid, cmd, uptr);
+}
 #endif
 
 static int testmsg(struct msg_msg *msg, long type, int mode)
index 34bbabc9e67246fd39aa95768e478ea34930a4ef..aa29b0802e260880a455c8ff8315b6fca4c1b20f 100644 (file)
@@ -70,7 +70,8 @@ SYSCALL_DEFINE6(ipc, unsigned int, call, int, first, unsigned long, second,
        case MSGGET:
                return ksys_msgget((key_t) first, second);
        case MSGCTL:
-               return sys_msgctl(first, second, (struct msqid_ds __user *)ptr);
+               return ksys_msgctl(first, second,
+                                  (struct msqid_ds __user *)ptr);
 
        case SHMAT:
                switch (version) {
@@ -163,7 +164,7 @@ COMPAT_SYSCALL_DEFINE6(ipc, u32, call, int, first, int, second,
        case MSGGET:
                return ksys_msgget(first, second);
        case MSGCTL:
-               return compat_sys_msgctl(first, second, compat_ptr(ptr));
+               return compat_ksys_msgctl(first, second, compat_ptr(ptr));
 
        case SHMAT: {
                int err;
index 16e8b5b8c416c090eb918e3d096c89a19cbe3977..47837b4af3f2647a17173b7a2949895585c48aa1 100644 (file)
@@ -243,6 +243,7 @@ long ksys_semtimedop(int semid, struct sembuf __user *tsops,
 long ksys_semget(key_t key, int nsems, int semflg);
 long ksys_semctl(int semid, int semnum, int cmd, unsigned long arg);
 long ksys_msgget(key_t key, int msgflg);
+long ksys_msgctl(int msqid, int cmd, struct msqid_ds __user *buf);
 long ksys_shmget(key_t key, size_t size, int shmflg);
 long ksys_shmdt(char __user *shmaddr);
 long ksys_shmctl(int shmid, int cmd, struct shmid_ds __user *buf);
@@ -253,6 +254,7 @@ long compat_ksys_semtimedop(int semid, struct sembuf __user *tsems,
                            unsigned int nsops,
                            const struct compat_timespec __user *timeout);
 long compat_ksys_semctl(int semid, int semnum, int cmd, int arg);
+long compat_ksys_msgctl(int msqid, int cmd, void __user *uptr);
 long compat_ksys_shmctl(int shmid, int cmd, void __user *uptr);
 #endif /* CONFIG_COMPAT */