Subject: Re: [PATCH net-next] 802: fix a possible race condition

From: Cong Wang <[email-masked]>
Date: Mon, 25 Mar 2013 21:32:18 +0800

On Sun, 2013-03-24 at 17:24 -0400, David Miller wrote:
> From: Cong Wang <[email-masked]>
> Date: Sat, 23 Mar 2013 13:14:08 +0800
> 
> > From: Cong Wang <[email-masked]>
> > 
> > garp_pdu_queue() should ways be called with this spin lock.
> > garp_uninit_applicant() only holds rtnl lock which is not
> > enough here.
> > 
> > Found by code inspection.
> > 
> > Cc: "David S. Miller" <[email-masked]>
> > Cc: David Ward <[email-masked]>
> > Cc: "Jorge Boncompte [DTI2]" <[email-masked]>
> > Signed-off-by: Cong Wang <[email-masked]>
> 
> Under what conditions can entries be removed or added to
> these RB-trees without the RTNL being held?

At least garp_join_timer() calls garp_pdu_queue() in a timer:

static void garp_join_timer(unsigned long data)
{
        struct garp_applicant *app = (struct garp_applicant *)data;

        spin_lock(&app->lock);
        garp_gid_event(app, GARP_EVENT_TRANSMIT_PDU);
        garp_pdu_queue(app);
        spin_unlock(&app->lock);

        garp_queue_xmit(app);
        garp_join_timer_arm(app);
}

which I don't think can hold RTNL lock possibly.

> 
> If such events cannot happen, then no locking is needed.
> 
> Even if your change is correct and necessary, the answer to my
> needs to be added to your commit message.

Ok, I will.

Thanks.