net_sched: hold tcf_lock in netdevice notifier
authorCong Wang <cwang@twopensource.com>
Wed, 16 Jul 2014 21:25:31 +0000 (14:25 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Jul 2014 03:31:42 +0000 (20:31 -0700)
We modify mirred action (m->tcfm_dev) in netdev event, we need to
prevent on-going mirred actions from reading freed m->tcfm_dev.
So we need to acquire this spin lock.

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "David S. Miller" <davem@davemloft.net>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_mirred.c

index 4f912c0e225b674dfa117060ee547b99feb972ca..eb48306033d91ef131fd67fcd432f73ed55a43cb 100644 (file)
@@ -218,10 +218,12 @@ static int mirred_device_event(struct notifier_block *unused,
 
        if (event == NETDEV_UNREGISTER)
                list_for_each_entry(m, &mirred_list, tcfm_list) {
+                       spin_lock_bh(&m->tcf_lock);
                        if (m->tcfm_dev == dev) {
                                dev_put(dev);
                                m->tcfm_dev = NULL;
                        }
+                       spin_unlock_bh(&m->tcf_lock);
                }
 
        return NOTIFY_DONE;