netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cong Wang <xiyou.wangcong@gmail.com>
To: netdev@vger.kernel.org
Cc: jiri@resnulli.us, jhs@mojatatu.com, vladbu@mellanox.com,
	Cong Wang <xiyou.wangcong@gmail.com>
Subject: [Patch net-next] net_sched: fix a crash in tc_new_tfilter()
Date: Thu, 27 Sep 2018 13:42:19 -0700	[thread overview]
Message-ID: <20180927204219.17846-2-xiyou.wangcong@gmail.com> (raw)
In-Reply-To: <20180927204219.17846-1-xiyou.wangcong@gmail.com>

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: e368fdb61d8e ("net: sched: use Qdisc rcu API instead of relying on rtnl lock")
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
 net/sched/cls_api.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 8dd7f8af6d54..a4167ec0a220 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -717,8 +717,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);
 }
 
-- 
2.14.4

  reply	other threads:[~2018-09-28  3:02 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-27 20:42 [Patch net-next] net_sched: fix an extack message in tcf_block_find() Cong Wang
2018-09-27 20:42 ` Cong Wang [this message]
2018-09-27 21:16 ` Eric Dumazet
2018-09-27 21:36   ` Cong Wang
2018-09-27 22:18     ` Eric Dumazet
2018-09-28 17:19       ` rcu_read_lock() " Cong Wang
2018-09-28  1:51     ` [Patch net-next] net_sched: fix an extack message " David Ahern
2018-09-28 11:36 ` Vlad Buslov
2018-09-28 17:03   ` Cong Wang
2018-09-30 14:12     ` Vlad Buslov
2018-09-28 17:04 ` Cong Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180927204219.17846-2-xiyou.wangcong@gmail.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=vladbu@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).