Skip to content

Commit

Permalink
af_unix: Don't use continue to re-execute unix_stream_read_generic loop
Browse files Browse the repository at this point in the history
The unix_stream_read_generic function tries to use a continue statement
to restart the receive loop after waiting for a message. This may not
work as intended as the caller might use a recvmsg call to peek at
control messages without specifying a message buffer. If this was the
case, the continue will cause the function to return without an error
and without the credential information if the function had to wait for a
message while it had returned with the credentials otherwise. Change to
using goto to restart the loop without checking the condition first in
this case so that credentials are returned either way.

Signed-off-by: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rainer Weikusat authored and davem330 committed Feb 20, 2016
1 parent b5f0549 commit 18eceb8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/unix/af_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -2312,6 +2312,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
bool drop_skb;
struct sk_buff *skb, *last;

redo:
unix_state_lock(sk);
if (sock_flag(sk, SOCK_DEAD)) {
err = -ECONNRESET;
Expand Down Expand Up @@ -2353,7 +2354,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
}

mutex_lock(&u->readlock);
continue;
goto redo;
unlock:
unix_state_unlock(sk);
break;
Expand Down

0 comments on commit 18eceb8

Please sign in to comment.