act_mirred: fix a race condition on mirred_list
authorWANG Cong <xiyou.wangcong@gmail.com>
Thu, 1 Oct 2015 18:37:42 +0000 (11:37 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Oct 2015 13:30:33 +0000 (06:30 -0700)
commit6bd00b850635abb0044e06101761533c8beba79c
tree65141acd5f97da77b3b997646ec270b4037ac1bb
parentfec31ffffa6e05845ab13908d0ac0d5a10816836
act_mirred: fix a race condition on mirred_list

After commit 1ce87720d456 ("net: sched: make cls_u32 lockless")
we began to release tc actions in a RCU callback. However,
mirred action relies on RTNL lock to protect the global
mirred_list, therefore we could have a race condition
between RCU callback and netdevice event, which caused
a list corruption as reported by Vinson.

Instead of relying on RTNL lock, introduce a spinlock to
protect this list.

Note, in non-bind case, it is still called with RTNL lock,
therefore should disable BH too.

Reported-by: Vinson Lee <vlee@twopensource.com>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/act_mirred.c