Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1585558 > unrolled thread

[PATCH] net: socket: fix recvmmsg not returning error from sock_error

Started byMaxime Jayat <maxime.jayat@mobile-devices.fr>
First post2017-02-21 18:40 +0100
Last post2017-02-21 19:40 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] net: socket: fix recvmmsg not returning error from sock_error Maxime Jayat <maxime.jayat@mobile-devices.fr> - 2017-02-21 18:40 +0100
    Re: [PATCH] net: socket: fix recvmmsg not returning error from  sock_error David Miller <davem@davemloft.net> - 2017-02-21 19:40 +0100

#1585558 — [PATCH] net: socket: fix recvmmsg not returning error from sock_error

FromMaxime Jayat <maxime.jayat@mobile-devices.fr>
Date2017-02-21 18:40 +0100
Subject[PATCH] net: socket: fix recvmmsg not returning error from sock_error
Message-ID<tdmzT-5Lh-1@gated-at.bofh.it>
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>
---
 net/socket.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/socket.c b/net/socket.c
index b7a63d5bc915..2c1e8677ff2d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2228,8 +2228,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;
-- 
2.9.3

[toc] | [next] | [standalone]


#1585614 — Re: [PATCH] net: socket: fix recvmmsg not returning error from sock_error

FromDavid Miller <davem@davemloft.net>
Date2017-02-21 19:40 +0100
SubjectRe: [PATCH] net: socket: fix recvmmsg not returning error from sock_error
Message-ID<tdnvZ-6me-33@gated-at.bofh.it>
In reply to#1585558
From: Maxime Jayat <maxime.jayat@mobile-devices.fr>
Date: Tue, 21 Feb 2017 18:35:51 +0100

> 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>

Good catch, applied and queued up for -stable.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web