Skip to content

Commit

Permalink
net_sched: fix a crash in tc_new_tfilter()
Browse files Browse the repository at this point in the history
commit 460b360 upstream.

When tcf_block_find() fails, it already rollbacks the qdisc refcnt,
so its caller doesn't need to clean up this again. Avoid calling
qdisc_put() again by resetting qdisc to NULL for callers.

Reported-by: syzbot+37b8770e6d5a8220a039@syzkaller.appspotmail.com
Fixes: e368fdb ("net: sched: use Qdisc rcu API instead of relying on rtnl lock")
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Cong Wang authored and Greg Kroah-Hartman committed Dec 14, 2021
1 parent d7b6d5f commit f9ff09e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,8 +629,10 @@ static struct tcf_block *tcf_block_find(struct net *net, struct Qdisc **q,
errout_rcu:
rcu_read_unlock();
errout_qdisc:
if (*q)
if (*q) {
qdisc_put(*q);
*q = NULL;
}
return ERR_PTR(err);
}

Expand Down

0 comments on commit f9ff09e

Please sign in to comment.