summaryrefslogtreecommitdiffstats
path: root/net/socket.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2019-12-06 18:38:36 +0100
committerDavid S. Miller <davem@davemloft.net>2019-12-06 21:06:44 +0100
commit1af66221a66de080274540a5c481ddacbe3574d2 (patch)
treea590d14576eeb53502e7d98d3a222e2368099c59 /net/socket.c
parentphy: mdio-thunder: add missed pci_release_regions in remove (diff)
downloadlinux-1af66221a66de080274540a5c481ddacbe3574d2.tar.xz
linux-1af66221a66de080274540a5c481ddacbe3574d2.zip
net: avoid an indirect call in ____sys_recvmsg()
CONFIG_RETPOLINE=y made indirect calls expensive. gcc seems to add an indirect call in ____sys_recvmsg(). Rewriting the code slightly makes sure to avoid this indirection. Alternative would be to not call sock_recvmsg() and instead use security_socket_recvmsg() and sock_recvmsg_nosec(), but this is less readable IMO. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Paolo Abeni <pabeni@redhat.com> Cc: David Laight <David.Laight@aculab.com> Acked-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to '')
-rw-r--r--net/socket.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/net/socket.c b/net/socket.c
index ea28cbb9e2e7..5af84d71cbc2 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2559,7 +2559,12 @@ static int ____sys_recvmsg(struct socket *sock, struct msghdr *msg_sys,
if (sock->file->f_flags & O_NONBLOCK)
flags |= MSG_DONTWAIT;
- err = (nosec ? sock_recvmsg_nosec : sock_recvmsg)(sock, msg_sys, flags);
+
+ if (unlikely(nosec))
+ err = sock_recvmsg_nosec(sock, msg_sys, flags);
+ else
+ err = sock_recvmsg(sock, msg_sys, flags);
+
if (err < 0)
goto out;
len = err;