]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
net_sched: carefully handle tcf_block_put()
authorCong Wang <xiyou.wangcong@gmail.com>
Mon, 11 Sep 2017 23:33:32 +0000 (16:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 13 Sep 2017 03:41:02 +0000 (20:41 -0700)
commit1697c4bb5245649a23f06a144cc38c06715e1b65
tree020f13f2d700eeb85998258429a05d119d689937
parente2ef75445340ca7ec2c4558f84ae6c8c5d650fc8
net_sched: carefully handle tcf_block_put()

As pointed out by Jiri, there is still a race condition between
tcf_block_put() and tcf_chain_destroy() in a RCU callback. There
is no way to make it correct without proper locking or synchronization,
because both operate on a shared list.

Locking is hard, because the only lock we can pick here is a spinlock,
however, in tc_dump_tfilter() we iterate this list with a sleeping
function called (tcf_chain_dump()), which makes using a lock to protect
chain_list almost impossible.

Jiri suggested the idea of holding a refcnt before flushing, this works
because it guarantees us there would be no parallel tcf_chain_destroy()
during the loop, therefore the race condition is gone. But we have to
be very careful with proper synchronization with RCU callbacks.

Suggested-by: Jiri Pirko <jiri@mellanox.com>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_api.c