Skip to contentSkip to conversation

802: fix a possible race condition

PATCH Applied Cong Wang 2 participants 2 messages Apr 3, 2013 – Apr 7, 2013

Subsystems (2)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 802: fix a possible race condition

From: Cong Wang <[email protected]>

(Resend with a better changelog)

garp_pdu_queue() should ways be called with this spin lock. garp_uninit_applicant() only holds rtnl lock which is not enough here. A possible race can happen as garp_pdu_rcv() is called in BH context:

	garp_pdu_rcv()
	  |->garp_pdu_parse_msg()
	    |->garp_pdu_parse_attr()
	      |-> garp_gid_event()

Found by code inspection.

Cc Eric Dumazet <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc David Ward <[email protected]>
Cc "Jorge Boncompte [DTI2]" <[email protected]>
---
 net/802/garp.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
net/802/garp.c +4 -0
index 8456f5d..5d9630a 100644
@@ -609,8 +609,12 @@ void garp_uninit_applicant(struct net_device *dev, struct garp_application *appl
 	/* Delete timer and generate a final TRANSMIT_PDU event to flush out
 	 * all pending messages before the applicant is gone. */
 	del_timer_sync(&app->join_timer);
+
+	spin_lock_bh(&app->lock);
 	garp_gid_event(app, GARP_EVENT_TRANSMIT_PDU);
 	garp_pdu_queue(app);
+	spin_unlock_bh(&app->lock);
+
 	garp_queue_xmit(app);
 
 	dev_mc_del(dev, appl->proto.group_address);
Signature · 1 line
1.7.7.6
maintainer Applied
#1 lore raw

From: Cong Wang <[email protected]>
Date: Wed, 3 Apr 2013 15:52:40 +0800

Quoted 14 lines

From: Cong Wang <[email protected]>

(Resend with a better changelog)

garp_pdu_queue() should ways be called with this spin lock. garp_uninit_applicant() only holds rtnl lock which is not enough here. A possible race can happen as garp_pdu_rcv() is called in BH context:

	garp_pdu_rcv()
	  |->garp_pdu_parse_msg()
	    |->garp_pdu_parse_attr()
	      |-> garp_gid_event()
Quoted 7 lines

Found by code inspection.

Cc Eric Dumazet <[email protected]>
Cc "David S. Miller" <[email protected]>
Cc David Ward <[email protected]>
Cc "Jorge Boncompte [DTI2]" <[email protected]>

Applied.