Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1337326 > unrolled thread

[PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop

Started byRainer Weikusat <rweikusat@mobileactivedefense.com>
First post2016-02-18 13:50 +0100
Last post2016-02-20 06:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop Rainer Weikusat <rweikusat@mobileactivedefense.com> - 2016-02-18 13:50 +0100
    Re: [PATCH net] af_unix: Don't use continue to re-execute  unix_stream_read_generic loop David Miller <davem@davemloft.net> - 2016-02-20 06:00 +0100

#1337326 — [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop

FromRainer Weikusat <rweikusat@mobileactivedefense.com>
Date2016-02-18 13:50 +0100
Subject[PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop
Message-ID<r3wbU-5xP-19@gated-at.bofh.it>
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;

[toc] | [next] | [standalone]


#1338633 — Re: [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop

FromDavid Miller <davem@davemloft.net>
Date2016-02-20 06:00 +0100
SubjectRe: [PATCH net] af_unix: Don't use continue to re-execute unix_stream_read_generic loop
Message-ID<r47Oa-82N-3@gated-at.bofh.it>
In reply to#1337326
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.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web