All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] packet: unconditionally free po->rollover
@ 2019-05-31 16:37 Willem de Bruijn
  2019-06-03  1:11 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Willem de Bruijn @ 2019-05-31 16:37 UTC (permalink / raw)
  To: netdev; +Cc: davem, Willem de Bruijn, syzbot, Dmitry Vyukov

From: Willem de Bruijn <willemb@google.com>

Rollover used to use a complex RCU mechanism for assignment, which had
a race condition. The below patch fixed the bug and greatly simplified
the logic.

The feature depends on fanout, but the state is private to the socket.
Fanout_release returns f only when the last member leaves and the
fanout struct is to be freed.

Destroy rollover unconditionally, regardless of fanout state.

Fixes: 57f015f5eccf2 ("packet: fix crash in fanout_demux_rollover()")
Reported-by: syzbot <syzkaller@googlegroups.com>
Diagnosed-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: Willem de Bruijn <willemb@google.com>
---
 net/packet/af_packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index fbc775fbf7128..d4889bf7248e1 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -3014,8 +3014,8 @@ static int packet_release(struct socket *sock)
 
 	synchronize_net();
 
+	kfree(po->rollover);
 	if (f) {
-		kfree(po->rollover);
 		fanout_release_data(f);
 		kfree(f);
 	}
-- 
2.22.0.rc1.257.g3120a18244-goog


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

* Re: [PATCH net] packet: unconditionally free po->rollover
  2019-05-31 16:37 [PATCH net] packet: unconditionally free po->rollover Willem de Bruijn
@ 2019-06-03  1:11 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-06-03  1:11 UTC (permalink / raw)
  To: willemdebruijn.kernel; +Cc: netdev, willemb, syzkaller, dvyukov

From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Date: Fri, 31 May 2019 12:37:23 -0400

> From: Willem de Bruijn <willemb@google.com>
> 
> Rollover used to use a complex RCU mechanism for assignment, which had
> a race condition. The below patch fixed the bug and greatly simplified
> the logic.
> 
> The feature depends on fanout, but the state is private to the socket.
> Fanout_release returns f only when the last member leaves and the
> fanout struct is to be freed.
> 
> Destroy rollover unconditionally, regardless of fanout state.
> 
> Fixes: 57f015f5eccf2 ("packet: fix crash in fanout_demux_rollover()")
> Reported-by: syzbot <syzkaller@googlegroups.com>
> Diagnosed-by: Dmitry Vyukov <dvyukov@google.com>
> Signed-off-by: Willem de Bruijn <willemb@google.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2019-06-03  1:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-31 16:37 [PATCH net] packet: unconditionally free po->rollover Willem de Bruijn
2019-06-03  1:11 ` 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.