From: Dominik Brodowski <linux@dominikbrodowski.net>
To: linux-kernel@vger.kernel.org, torvalds@linux-foundation.org,
davem@davemloft.net
Cc: netdev@vger.kernel.org
Subject: [PATCH -next 04/22] net: socket: add __sys_socket() helper; remove in-kernel call to syscall
Date: Fri, 16 Mar 2018 18:05:56 +0100 [thread overview]
Message-ID: <20180316170614.5392-5-linux@dominikbrodowski.net> (raw)
In-Reply-To: <20180316170614.5392-1-linux@dominikbrodowski.net>
Using the net-internal helper __sys_socket() allows us to avoid the
internal calls to the sys_socket() syscall.
Cc: David S. Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Signed-off-by: Dominik Brodowski <linux@dominikbrodowski.net>
---
include/linux/socket.h | 1 +
net/compat.c | 2 +-
net/socket.c | 9 +++++++--
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 6a9840271676..f8d040434a13 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -363,5 +363,6 @@ extern int __sys_sendto(int fd, void __user *buff, size_t len,
int addr_len);
extern int __sys_accept4(int fd, struct sockaddr __user *upeer_sockaddr,
int __user *upeer_addrlen, int flags);
+extern int __sys_socket(int family, int type, int protocol);
#endif /* _LINUX_SOCKET_H */
diff --git a/net/compat.c b/net/compat.c
index 0ff9f7451b6f..5b3b74c5812e 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -811,7 +811,7 @@ COMPAT_SYSCALL_DEFINE2(socketcall, int, call, u32 __user *, args)
switch (call) {
case SYS_SOCKET:
- ret = sys_socket(a0, a1, a[2]);
+ ret = __sys_socket(a0, a1, a[2]);
break;
case SYS_BIND:
ret = sys_bind(a0, compat_ptr(a1), a[2]);
diff --git a/net/socket.c b/net/socket.c
index 45f6ea0d57a5..07f379e50def 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -1332,7 +1332,7 @@ int sock_create_kern(struct net *net, int family, int type, int protocol, struct
}
EXPORT_SYMBOL(sock_create_kern);
-SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
+int __sys_socket(int family, int type, int protocol)
{
int retval;
struct socket *sock;
@@ -1359,6 +1359,11 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
return sock_map_fd(sock, flags & (O_CLOEXEC | O_NONBLOCK));
}
+SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
+{
+ return __sys_socket(family, type, protocol);
+}
+
/*
* Create a pair of connected sockets.
*/
@@ -2463,7 +2468,7 @@ SYSCALL_DEFINE2(socketcall, int, call, unsigned long __user *, args)
switch (call) {
case SYS_SOCKET:
- err = sys_socket(a0, a1, a[2]);
+ err = __sys_socket(a0, a1, a[2]);
break;
case SYS_BIND:
err = sys_bind(a0, (struct sockaddr __user *)a1, a[2]);
--
2.16.2
next prev parent reply other threads:[~2018-03-16 17:05 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-16 17:05 [PATCH -next 00/22] remove in-kernel syscall invocations (part 2 == netdev) Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 01/22] net: socket: add __sys_recvfrom() helper; remove in-kernel call to syscall Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 02/22] net: socket: add __sys_sendto() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 03/22] net: socket: add __sys_accept4() " Dominik Brodowski
2018-03-16 17:05 ` Dominik Brodowski [this message]
2018-03-16 17:05 ` [PATCH -next 05/22] net: socket: add __sys_bind() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 06/22] net: socket: add __sys_connect() " Dominik Brodowski
2018-03-16 17:05 ` [PATCH -next 07/22] net: socket: add __sys_listen() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 08/22] net: socket: add __sys_getsockname() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 09/22] net: socket: add __sys_getpeername() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 10/22] net: socket: add __sys_socketpair() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 11/22] net: socket: add __sys_shutdown() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 12/22] net: socket: add __sys_setsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 13/22] net: socket: add __sys_getsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 14/22] net: socket: add do_sys_recvmmsg() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 15/22] net: socket: move check for forbid_cmsg_compat to __sys_...msg() Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 16/22] net: socket: replace calls to sys_send() with __sys_sendto() Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 17/22] net: socket: replace call to sys_recv() with __sys_recvfrom() Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 18/22] net: socket: add __compat_sys_recvfrom() helper; remove in-kernel call to compat syscall Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 19/22] net: socket: add __compat_sys_setsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 20/22] net: socket: add __compat_sys_getsockopt() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 21/22] net: socket: add __compat_sys_recvmmsg() " Dominik Brodowski
2018-03-16 17:06 ` [PATCH -next 22/22] net: socket: add __compat_sys_...msg() helpers; remove in-kernel calls to compat syscalls Dominik Brodowski
2018-03-16 18:30 ` [PATCH -next 00/22] remove in-kernel syscall invocations (part 2 == netdev) David Miller
2018-03-16 19:39 ` Dominik Brodowski
2018-03-16 19:42 ` Linus Torvalds
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=20180316170614.5392-5-linux@dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=davem@davemloft.net \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/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).