Skip to contentSkip to conversation

packet: unconditionally free po->rollover

PATCH In review Willem de Bruijn 2 participants 2 messages May 31, 2019 – Jun 3, 2019

Subsystems (3)
lore
Share & tools
lore

Willem de Bruijn

author maintainer
#0 lore raw

PATCH 1/1 packet: unconditionally free po->rollover

From: Willem de Bruijn <[email protected]>

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()")
---
 net/packet/af_packet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/packet/af_packet.c +1 -1
index fbc775fbf7128..d4889bf7248e1 100644
@@ -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);
 	}
Signature · 1 line
2.22.0.rc1.257.g3120a18244-goog
maintainer
#1 lore raw

From: Willem de Bruijn <[email protected]>
Date: Fri, 31 May 2019 12:37:23 -0400

Quoted 10 lines

From: Willem de Bruijn <[email protected]>

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.

Quoted 6 lines

Destroy rollover unconditionally, regardless of fanout state.

Fixes 57f015f5eccf2 ("packet: fix crash in fanout_demux_rollover()")

Applied and queued up for -stable.