提交 18eceb81 编写于 作者: R Rainer Weikusat 提交者: David S. Miller

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: NRainer Weikusat <rweikusat@mobileactivedefense.com>
Acked-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b5f05492
...@@ -2312,6 +2312,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) ...@@ -2312,6 +2312,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
bool drop_skb; bool drop_skb;
struct sk_buff *skb, *last; struct sk_buff *skb, *last;
redo:
unix_state_lock(sk); unix_state_lock(sk);
if (sock_flag(sk, SOCK_DEAD)) { if (sock_flag(sk, SOCK_DEAD)) {
err = -ECONNRESET; err = -ECONNRESET;
...@@ -2353,7 +2354,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state) ...@@ -2353,7 +2354,7 @@ static int unix_stream_read_generic(struct unix_stream_read_state *state)
} }
mutex_lock(&u->readlock); mutex_lock(&u->readlock);
continue; goto redo;
unlock: unlock:
unix_state_unlock(sk); unix_state_unlock(sk);
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册