From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-kernel@vger.kernel.org
Cc: viro@ZenIV.linux.org.uk, torvalds@linux-foundation.org,
arnd@arndb.de, linux-arch@vger.kernel.org,
"David S . Miller" <davem@davemloft.net>,
netdev@vger.kernel.org
Subject: [PATCH 029/109] net: socket: add __compat_sys_...msg() helpers; remove in-kernel calls to compat syscalls
Date: Thu, 29 Mar 2018 13:23:06 +0200 [thread overview]
Message-ID: <20180329112426.23043-30-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20180329112426.23043-1-linux@dominikbrodowski.net>
Using the net-internal helpers __compat_sys_...msg() allows us to avoid
the internal calls to the compat_sys_...msg() syscalls.
compat_sys_recvmmsg() is handled in a different patch.
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: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
net/compat.c | 37 ++++++++++++++++++++++++++++++-------
1 file changed, 30 insertions(+), 7 deletions(-)
diff --git a/net/compat.c b/net/compat.c
index 7b2ae42a1598..5ae7437d3853 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -747,25 +747,48 @@ static unsigned char nas[21] = {
};
#undef AL
-COMPAT_SYSCALL_DEFINE3(sendmsg, int, fd, struct compat_msghdr __user *, msg, unsigned int, flags)
+static inline long __compat_sys_sendmsg(int fd,
+ struct compat_msghdr __user *msg,
+ unsigned int flags)
{
return __sys_sendmsg(fd, (struct user_msghdr __user *)msg,
flags | MSG_CMSG_COMPAT, false);
}
-COMPAT_SYSCALL_DEFINE4(sendmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,
- unsigned int, vlen, unsigned int, flags)
+COMPAT_SYSCALL_DEFINE3(sendmsg, int, fd, struct compat_msghdr __user *, msg,
+ unsigned int, flags)
+{
+ return __compat_sys_sendmsg(fd, msg, flags);
+}
+
+static inline long __compat_sys_sendmmsg(int fd,
+ struct compat_mmsghdr __user *mmsg,
+ unsigned int vlen, unsigned int flags)
{
return __sys_sendmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
flags | MSG_CMSG_COMPAT, false);
}
-COMPAT_SYSCALL_DEFINE3(recvmsg, int, fd, struct compat_msghdr __user *, msg, unsigned int, flags)
+COMPAT_SYSCALL_DEFINE4(sendmmsg, int, fd, struct compat_mmsghdr __user *, mmsg,
+ unsigned int, vlen, unsigned int, flags)
+{
+ return __compat_sys_sendmmsg(fd, mmsg, vlen, flags);
+}
+
+static inline long __compat_sys_recvmsg(int fd,
+ struct compat_msghdr __user *msg,
+ unsigned int flags)
{
return __sys_recvmsg(fd, (struct user_msghdr __user *)msg,
flags | MSG_CMSG_COMPAT, false);
}
+COMPAT_SYSCALL_DEFINE3(recvmsg, int, fd, struct compat_msghdr __user *, msg,
+ unsigned int, flags)
+{
+ return __compat_sys_recvmsg(fd, msg, flags);
+}
+
static inline long __compat_sys_recvfrom(int fd, void __user *buf,
compat_size_t len, unsigned int flags,
struct sockaddr __user *addr,
@@ -893,13 +916,13 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
compat_ptr(a[4]));
break;
case SYS_SENDMSG:
- ret = compat_sys_sendmsg(a0, compat_ptr(a1), a[2]);
+ ret = __compat_sys_sendmsg(a0, compat_ptr(a1), a[2]);
break;
case SYS_SENDMMSG:
- ret = compat_sys_sendmmsg(a0, compat_ptr(a1), a[2], a[3]);
+ ret = __compat_sys_sendmmsg(a0, compat_ptr(a1), a[2], a[3]);
break;
case SYS_RECVMSG:
- ret = compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
+ ret = __compat_sys_recvmsg(a0, compat_ptr(a1), a[2]);
break;
case SYS_RECVMMSG:
ret = __compat_sys_recvmmsg(a0, compat_ptr(a1), a[2], a[3],
--
2.16.3
next prev parent reply other threads:[~2018-03-29 11:23 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-29 11:22 [PATCH 000/109] remove in-kernel calls to syscalls Dominik Brodowski
2018-03-29 11:22 ` [PATCH 008/109] net: socket: add __sys_recvfrom() helper; remove in-kernel call to syscall Dominik Brodowski
2018-03-29 11:22 ` [PATCH 009/109] net: socket: add __sys_sendto() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 010/109] net: socket: add __sys_accept4() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 011/109] net: socket: add __sys_socket() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 012/109] net: socket: add __sys_bind() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 013/109] net: socket: add __sys_connect() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 014/109] net: socket: add __sys_listen() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 015/109] net: socket: add __sys_getsockname() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 016/109] net: socket: add __sys_getpeername() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 017/109] net: socket: add __sys_socketpair() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 018/109] net: socket: add __sys_shutdown() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 019/109] net: socket: add __sys_setsockopt() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 020/109] net: socket: add __sys_getsockopt() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 021/109] net: socket: add do_sys_recvmmsg() " Dominik Brodowski
2018-03-29 11:22 ` [PATCH 022/109] net: socket: move check for forbid_cmsg_compat to __sys_...msg() Dominik Brodowski
2018-03-29 11:23 ` [PATCH 023/109] net: socket: replace calls to sys_send() with __sys_sendto() Dominik Brodowski
2018-03-29 11:23 ` [PATCH 024/109] net: socket: replace call to sys_recv() with __sys_recvfrom() Dominik Brodowski
2018-03-29 11:23 ` [PATCH 025/109] net: socket: add __compat_sys_recvfrom() helper; remove in-kernel call to compat syscall Dominik Brodowski
2018-03-29 11:23 ` [PATCH 026/109] net: socket: add __compat_sys_setsockopt() " Dominik Brodowski
2018-03-29 11:23 ` [PATCH 027/109] net: socket: add __compat_sys_getsockopt() " Dominik Brodowski
2018-03-29 11:23 ` [PATCH 028/109] net: socket: add __compat_sys_recvmmsg() " Dominik Brodowski
2018-03-29 11:23 ` Dominik Brodowski [this message]
2018-03-29 11:24 ` [PATCH 104/109] net: remove compat_sys_*() prototypes from net/compat.h Dominik Brodowski
2018-03-29 11:24 ` [PATCH 106/109] syscalls/x86: auto-create compat_sys_*() prototypes Dominik Brodowski
2018-03-29 14:20 ` [PATCH 000/109] remove in-kernel calls to syscalls Matthew Wilcox
2018-03-29 14:42 ` Dominik Brodowski
2018-03-29 14:46 ` David Laight
2018-03-29 14:55 ` Dominik Brodowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180329112426.23043-30-linux@dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=arnd@arndb.de \
--cc=davem@davemloft.net \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).