Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

af_unix: Don't use continue to re-execute unix_stream_read_generic loop

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>

authored by

Rainer Weikusat and committed by
David S. Miller
18eceb81 b5f05492

+2 -1
+2 -1
net/unix/af_unix.c
··· 2312 2312 bool drop_skb; 2313 2313 struct sk_buff *skb, *last; 2314 2314 2315 + redo: 2315 2316 unix_state_lock(sk); 2316 2317 if (sock_flag(sk, SOCK_DEAD)) { 2317 2318 err = -ECONNRESET; ··· 2354 2353 } 2355 2354 2356 2355 mutex_lock(&u->readlock); 2357 - continue; 2356 + goto redo; 2358 2357 unlock: 2359 2358 unix_state_unlock(sk); 2360 2359 break;