net: socket: fix recvmmsg not returning error from sock_error
authorMaxime Jayat <maxime.jayat@mobile-devices.fr>
Tue, 21 Feb 2017 17:35:51 +0000 (18:35 +0100)
committerWilly Tarreau <w@1wt.eu>
Wed, 7 Jun 2017 22:46:59 +0000 (00:46 +0200)
commit0b5240c45e2029986526b1405ab24906c708f770
tree6218546781c87040b082fa67f63b7a6f2f652b70
parent9aab35929faed156ca7ade4bd412621f527756f2
net: socket: fix recvmmsg not returning error from sock_error

commit e623a9e9dec29ae811d11f83d0074ba254aba374 upstream.

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: Willy Tarreau <w@1wt.eu>
net/socket.c