net_sched: introduce a workqueue for RCU callbacks of tc filter
authorCong Wang <xiyou.wangcong@gmail.com>
Fri, 27 Oct 2017 01:24:28 +0000 (18:24 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 29 Oct 2017 13:49:30 +0000 (22:49 +0900)
commit7aa0045dadb6ef37485ea9f2a7d28278ca588b51
treee3c535a5d93bef05b780d64e220039f360e19104
parent8c83c88584abb3a04a4026be91060bc309f4c034
net_sched: introduce a workqueue for RCU callbacks of tc filter

This patch introduces a dedicated workqueue for tc filters
so that each tc filter's RCU callback could defer their
action destroy work to this workqueue. The helper
tcf_queue_work() is introduced for them to use.

Because we hold RTNL lock when calling tcf_block_put(), we
can not simply flush works inside it, therefore we have to
defer it again to this workqueue and make sure all flying RCU
callbacks have already queued their work before this one, in
other words, to ensure this is the last one to execute to
prevent any use-after-free.

On the other hand, this makes tcf_block_put() ugly and
harder to understand. Since David and Eric strongly dislike
adding synchronize_rcu(), this is probably the only
solution that could make everyone happy.

Please also see the code comments below.

Reported-by: Chris Mi <chrism@mellanox.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jiri Pirko <jiri@resnulli.us>
Cc: John Fastabend <john.fastabend@gmail.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/pkt_cls.h
include/net/sch_generic.h
net/sched/cls_api.c