Cong Wang 95278ddaa1 net_sched: convert idrinfo->lock from spinlock to a mutex
In commit ec3ed293e766 ("net_sched: change tcf_del_walker() to take idrinfo->lock")
we move fl_hw_destroy_tmplt() to a workqueue to avoid blocking
with the spinlock held. Unfortunately, this causes a lot of
troubles here:

1. tcf_chain_destroy() could be called right after we queue the work
   but before the work runs. This is a use-after-free.

2. The chain refcnt is already 0, we can't even just hold it again.
   We can check refcnt==1 but it is ugly.

3. The chain with refcnt 0 is still visible in its block, which means
   it could be still found and used!

4. The block has a refcnt too, we can't hold it without introducing a
   proper API either.

We can make it working but the end result is ugly. Instead of wasting
time on reviewing it, let's just convert the troubling spinlock to
a mutex, which allows us to use non-atomic allocations too.

Fixes: ec3ed293e766 ("net_sched: change tcf_del_walker() to take idrinfo->lock")
Reported-by: Ido Schimmel <idosch@idosch.org>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Vlad Buslov <vladbu@mellanox.com>
Cc: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Tested-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2018-10-05 00:36:31 -07:00
..
2018-01-19 14:02:12 -05:00
2018-09-18 19:55:01 -07:00
2018-05-16 07:23:35 +02:00
2018-09-26 20:22:19 -07:00
2018-07-30 09:10:25 -07:00
2018-02-28 11:43:28 -05:00
2018-04-23 10:21:24 -04:00
2017-10-11 09:49:34 +02:00
2017-12-11 14:10:06 -05:00
2017-12-15 12:34:00 -05:00
2018-10-04 21:54:25 -07:00
2018-09-13 09:04:58 -07:00
2018-04-07 22:32:31 -04:00
2017-11-08 16:12:33 +09:00
2018-10-04 21:42:28 -07:00
2018-09-25 20:17:35 -07:00
2018-05-16 07:23:35 +02:00
2017-12-05 14:37:13 -05:00
2018-05-16 07:23:35 +02:00
2018-06-22 13:43:27 +09:00
2018-06-22 13:43:27 +09:00
2018-10-01 23:18:51 -07:00
2018-08-29 12:25:53 -07:00