All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop
@ 2016-02-18 12:39 Rainer Weikusat
  2016-02-20  4:51 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Rainer Weikusat @ 2016-02-18 12:39 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel, hannes, joseph.salisbury, edumazet, rweikusat

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>
---

I'm resending this as the original patch seems to have been classified
as superseded without anything actually superseding it. I hope the net
is appropriate. I consider this a bugfix.

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index c51e283..f75f847 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -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;
@@ -2353,7 +2354,7 @@ again:
 			}
 
 			mutex_lock(&u->readlock);
-			continue;
+			goto redo;
 unlock:
 			unix_state_unlock(sk);
 			break;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop
  2016-02-18 12:39 [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop Rainer Weikusat
@ 2016-02-20  4:51 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-02-20  4:51 UTC (permalink / raw)
  To: rweikusat; +Cc: netdev, linux-kernel, hannes, joseph.salisbury, edumazet

From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Date: Thu, 18 Feb 2016 12:39:46 +0000

> 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>

Applied, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-02-20  4:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-18 12:39 [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop Rainer Weikusat
2016-02-20  4:51 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.