socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE)
Subsystems (3)
PATCH 1/1 socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE)
From: Soheil Hassas Yeganeh <[email protected]>
recvmmsg does not call ___sys_recvmsg when sk_err is set. That is fine for normal reads but, for MSG_ERRQUEUE, recvmmsg should always call ___sys_recvmsg regardless of sk->sk_err to be able to clear error queue. Otherwise, users are not able to drain the error queue using recvmmsg.
--- net/socket.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
net/socket.c +6 -4
@@ -2289,10 +2289,12 @@ int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,if (!sock)return err; - err =sock_error (sock->sk); -if (err) { - datagrams = err; - goto out_put; +if (likely (!(flags &MSG_ERRQUEUE ))) { + err =sock_error (sock->sk); +if (err) { + datagrams = err; + goto out_put; + } } entry = mmsg;
Signature · 1 line
2.16.2.395.g2e18187dfd-goog
From: Soheil Hassas Yeganeh <[email protected]>
Date: Tue, 27 Feb 2018 18:22:40 -0500
Quoted 11 lines
From: Soheil Hassas Yeganeh <[email protected]>
recvmmsg does not call
___sys_recvmsgwhensk_erris set. That is fine for normal reads but, forMSG_ERRQUEUE, recvmmsg should always call___sys_recvmsgregardless ofsk->sk_errto be able to clear error queue. Otherwise, users are not able to drain the error queue using recvmmsg.Signed-off-by Soheil Hassas Yeganeh <[email protected]>Reviewed-by Eric Dumazet <[email protected]>Signed-off-by Willem de Bruijn <[email protected]>
Applied, thank you.