From: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org, edumazet@google.com, jhs@mojatatu.com,
xiyou.wangcong@gmail.com, jiri@resnulli.us,
roopa@cumulusnetworks.com
Subject: Re: [PATCH net] sch_htb: fix crash on init failure
Date: Tue, 29 Aug 2017 21:19:05 +0300 [thread overview]
Message-ID: <3a6ccb7f-7339-3a24-128e-a858e4fc26fc@cumulusnetworks.com> (raw)
In-Reply-To: <1504030196.11498.82.camel@edumazet-glaptop3.roam.corp.google.com>
On 29/08/17 21:09, Eric Dumazet wrote:
> On Tue, 2017-08-29 at 20:58 +0300, Nikolay Aleksandrov wrote:
>> The commit below added a call to the ->destroy() callback for all qdiscs
>> which failed in their ->init(), but some were not prepared for such
>> change and can't handle partially initialized qdisc. HTB is one of them
>> and if any error occurs before the qdisc watchdog timer and qdisc work are
>> initialized then we can hit either a null ptr deref (timer->base) when
>> canceling in ->destroy or lockdep error info about trying to register
>> a non-static key and a stack dump. So to fix these two move the watchdog
>> timer and workqueue init before anything that can err out.
>> To reproduce userspace needs to send broken htb qdisc create request,
>> tested with a modified tc (q_htb.c).
>
>> Note that probably this bug goes further back because the default qdisc
>> handling always calls ->destroy on init failure too.
>>
>> Fixes: 87b60cfacf9f ("net_sched: fix error recovery at qdisc creation")
>> Signed-off-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
>> ---
>> Always calling qdisc destroy on init failure in the default qdisc handling
>> was added in commit 0fbbeb1ba43b. I'm not sure if I should include that
>> one as fixes tag.
>
> Well, we probably need to audit init/destroy not only in net/sched, but
> other parts of networking stack.
>
I'm not sure I follow, I hit this while working on a net/sched/ patch and had to error
out in the init() function.
> What about the qdisc_skb_head_init(&q->direct_queue) call ?
>
> I am surprised you do not crash in __skb_queue_purge(&q->direct_queue);
>
Hm, do you mean in __qdisc_reset_queue() ?
I have only tried/seen the crash happen on qdisc add.
A much simpler and easier bug is sch_multiq (ethX non-multiq):
$ tc qdisc add dev ethX root multiq
(error EOPNOTSUPP + double free of ->queues due to free in init())
and e.g. $ ip l add dumdum type dummy
to see a crash due to the corrupted memory.
next prev parent reply other threads:[~2017-08-29 18:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 17:58 [PATCH net] sch_htb: fix crash on init failure Nikolay Aleksandrov
2017-08-29 18:09 ` Eric Dumazet
2017-08-29 18:13 ` Cong Wang
2017-08-29 18:23 ` Eric Dumazet
2017-08-29 18:14 ` Eric Dumazet
2017-08-29 18:19 ` Nikolay Aleksandrov [this message]
2017-08-29 18:20 ` Cong Wang
2017-08-29 23:06 ` David Miller
2017-08-29 23:11 ` Nikolay Aleksandrov
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=3a6ccb7f-7339-3a24-128e-a858e4fc26fc@cumulusnetworks.com \
--to=nikolay@cumulusnetworks.com \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=netdev@vger.kernel.org \
--cc=roopa@cumulusnetworks.com \
--cc=xiyou.wangcong@gmail.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