Skip to content

Commit

Permalink
802: fix a possible race condition
Browse files Browse the repository at this point in the history
(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]>
Signed-off-by: Cong Wang <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Cong Wang authored and davem330 committed Apr 7, 2013
1 parent 23a9544 commit cfbe800
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/802/garp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cfbe800

Please sign in to comment.