All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] af_unix: don't append consumed skbs to sk_receive_queue
@ 2015-11-16 15:25 Hannes Frederic Sowa
  2015-11-16 16:38 ` Eric Dumazet
  2015-11-16 20:40 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Hannes Frederic Sowa @ 2015-11-16 15:25 UTC (permalink / raw)
  To: netdev; +Cc: Hannes Frederic Sowa, Dmitry Vyukov, Eric Dumazet

In case multiple writes to a unix stream socket race we could end up in a
situation where we pre-allocate a new skb for use in unix_stream_sendpage
but have to free it again in the locked section because another skb
has been appended meanwhile, which we must use. Accidentally we didn't
clear the pointer after consuming it and so we touched freed memory
while appending it to the sk_receive_queue. So, clear the pointer after
consuming the skb.

This bug has been found with syzkaller
(http://github.com/google/syzkaller) by Dmitry Vyukov.

Fixes: 869e7c62486e ("net: af_unix: implement stream sendpage support")
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
---
 net/unix/af_unix.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index aaa0b58..c6eb2e8 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1799,6 +1799,7 @@ alloc_skb:
 		 * this - does no harm
 		 */
 		consume_skb(newskb);
+		newskb = NULL;
 	}
 
 	if (skb_append_pagefrags(skb, page, offset, size)) {
-- 
2.5.0

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

* Re: [PATCH net] af_unix: don't append consumed skbs to sk_receive_queue
  2015-11-16 15:25 [PATCH net] af_unix: don't append consumed skbs to sk_receive_queue Hannes Frederic Sowa
@ 2015-11-16 16:38 ` Eric Dumazet
  2015-11-16 20:40 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Dumazet @ 2015-11-16 16:38 UTC (permalink / raw)
  To: Hannes Frederic Sowa; +Cc: netdev, Dmitry Vyukov

On Mon, 2015-11-16 at 16:25 +0100, Hannes Frederic Sowa wrote:
> In case multiple writes to a unix stream socket race we could end up in a
> situation where we pre-allocate a new skb for use in unix_stream_sendpage
> but have to free it again in the locked section because another skb
> has been appended meanwhile, which we must use. Accidentally we didn't
> clear the pointer after consuming it and so we touched freed memory
> while appending it to the sk_receive_queue. So, clear the pointer after
> consuming the skb.
> 
> This bug has been found with syzkaller
> (http://github.com/google/syzkaller) by Dmitry Vyukov.
> 
> Fixes: 869e7c62486e ("net: af_unix: implement stream sendpage support")
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> ---

Acked-by: Eric Dumazet <edumazet@google.com>

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

* Re: [PATCH net] af_unix: don't append consumed skbs to sk_receive_queue
  2015-11-16 15:25 [PATCH net] af_unix: don't append consumed skbs to sk_receive_queue Hannes Frederic Sowa
  2015-11-16 16:38 ` Eric Dumazet
@ 2015-11-16 20:40 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2015-11-16 20:40 UTC (permalink / raw)
  To: hannes; +Cc: netdev, dvyukov, eric.dumazet

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Mon, 16 Nov 2015 16:25:56 +0100

> In case multiple writes to a unix stream socket race we could end up in a
> situation where we pre-allocate a new skb for use in unix_stream_sendpage
> but have to free it again in the locked section because another skb
> has been appended meanwhile, which we must use. Accidentally we didn't
> clear the pointer after consuming it and so we touched freed memory
> while appending it to the sk_receive_queue. So, clear the pointer after
> consuming the skb.
> 
> This bug has been found with syzkaller
> (http://github.com/google/syzkaller) by Dmitry Vyukov.
> 
> Fixes: 869e7c62486e ("net: af_unix: implement stream sendpage support")
> Reported-by: Dmitry Vyukov <dvyukov@google.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Cc: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>

Applied and queued up for -stable, thanks.

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

end of thread, other threads:[~2015-11-16 20:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-16 15:25 [PATCH net] af_unix: don't append consumed skbs to sk_receive_queue Hannes Frederic Sowa
2015-11-16 16:38 ` Eric Dumazet
2015-11-16 20:40 ` 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.