Skip to content

Commit

Permalink
socket: skip checking sk_err for recvmmsg(MSG_ERRQUEUE)
Browse files Browse the repository at this point in the history
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.

Signed-off-by: Soheil Hassas Yeganeh <soheil@google.com>
Reviewed-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Soheil Hassas Yeganeh authored and David S. Miller committed Mar 2, 2018
1 parent 96dbdc5 commit 7797dc4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 7797dc4

Please sign in to comment.