summaryrefslogtreecommitdiff
path: root/net/socket.c
diff options
context:
space:
mode:
authorMaxime Jayat <maxime.jayat@mobile-devices.fr>2017-02-21 18:35:51 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-26 11:10:51 +0100
commit1a0e2594ef76fabe28049922c20d19c12aad4881 (patch)
treedc2f5018c90d0ad6b504e71270e333cdb071fafa /net/socket.c
parent481aedf869fbf2d4503ca0005dbd68b78422955a (diff)
net: socket: fix recvmmsg not returning error from sock_error
[ Upstream commit e623a9e9dec29ae811d11f83d0074ba254aba374 ] Commit 34b88a68f26a ("net: Fix use after free in the recvmmsg exit path"), changed the exit path of recvmmsg to always return the datagrams variable and modified the error paths to set the variable to the error code returned by recvmsg if necessary. However in the case sock_error returned an error, the error code was then ignored, and recvmmsg returned 0. Change the error path of recvmmsg to correctly return the error code of sock_error. The bug was triggered by using recvmmsg on a CAN interface which was not up. Linux 4.6 and later return 0 in this case while earlier releases returned -ENETDOWN. Fixes: 34b88a68f26a ("net: Fix use after free in the recvmmsg exit path") Signed-off-by: Maxime Jayat <maxime.jayat@mobile-devices.fr> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/socket.c')
-rw-r--r--net/socket.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/net/socket.c b/net/socket.c
index 73dc69f9681e..6bbccf05854f 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2197,8 +2197,10 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
return err;
err = sock_error(sock->sk);
- if (err)
+ if (err) {
+ datagrams = err;
goto out_put;
+ }
entry = mmsg;
compat_entry = (struct compat_mmsghdr __user *)mmsg;