]> git.baikalelectronics.ru Git - kernel.git/commit
net_sched: hold rtnl lock in tcindex_partial_destroy_work()
authorCong Wang <xiyou.wangcong@gmail.com>
Thu, 12 Mar 2020 05:42:27 +0000 (22:42 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sun, 15 Mar 2020 03:41:17 +0000 (20:41 -0700)
commita50f657bf66e1ccc9e7f07f2232a9d47578bfd3e
tree354a128e161f6afef1855d37fb332f6db2381020
parenta0ac02409133295da75a46a331241877fc48b827
net_sched: hold rtnl lock in tcindex_partial_destroy_work()

syzbot reported a use-after-free in tcindex_dump(). This is due to
the lack of RTNL in the deferred rcu work. We queue this work with
RTNL in tcindex_change(), later, tcindex_dump() is called:

        fh = tp->ops->get(tp, t->tcm_handle);
...
        err = tp->ops->change(..., &fh, ...);
        tfilter_notify(..., fh, ...);

but there is nothing to serialize the pending
tcindex_partial_destroy_work() with tcindex_dump().

Fix this by simply holding RTNL in tcindex_partial_destroy_work(),
so that it won't be called until RTNL is released after
tc_new_tfilter() is completed.

Reported-and-tested-by: syzbot+653090db2562495901dc@syzkaller.appspotmail.com
Fixes: c0ba7bbd3e74 ("net_sched: fix a race condition in tcindex_destroy()")
Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Jiri Pirko <jiri@resnulli.us>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_tcindex.c