netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Buslov <vladbu@mellanox.com>
To: Cong Wang <xiyou.wangcong@gmail.com>, Matteo Croce <mcroce@redhat.com>
Cc: Vlad Buslov <vladbu@mellanox.com>,
	Linux Kernel Network Developers <netdev@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH net] cls_matchall: avoid panic when receiving a packet before filter set
Date: Fri, 3 May 2019 09:03:11 +0000	[thread overview]
Message-ID: <vbf8svnq59y.fsf@mellanox.com> (raw)
In-Reply-To: <CAM_iQpXNdZPAWiGuwRGhgX4WdRGEwVnax5VyMrXZ+hM9xhhzCQ@mail.gmail.com>

On Thu 02 May 2019 at 03:48, Cong Wang <xiyou.wangcong@gmail.com> wrote:
> On Wed, May 1, 2019 at 2:27 AM Matteo Croce <mcroce@redhat.com> wrote:
>>
>> On Tue, Apr 30, 2019 at 11:25 PM Cong Wang <xiyou.wangcong@gmail.com> wrote:
>> >
>> > On Mon, Apr 29, 2019 at 10:38 AM Matteo Croce <mcroce@redhat.com> wrote:
>> > >
>> > > When a matchall classifier is added, there is a small time interval in
>> > > which tp->root is NULL. If we receive a packet in this small time slice
>> > > a NULL pointer dereference will happen, leading to a kernel panic:
>> >
>> > Hmm, why not just check tp->root against NULL in mall_classify()?
>> >
>> > Also, which is the offending commit here? Please add a Fixes: tag.
>> >
>> > Thanks.
>>
>> Hi,
>>
>> I just want to avoid an extra check which would be made for every packet.
>> Probably the benefit over a check is negligible, but it's still a
>> per-packet thing.
>> If you prefer a simple check, I can make a v2 that way.
>
> Yeah, I think that is better, you can add an unlikely() for performance
> concern, as NULL is a rare case.
>
>
>>
>> For the fixes tag, I didn't put it as I'm not really sure about the
>> offending commit. I guess it's the following, what do you think?
>>
>> commit ed76f5edccc98fa66f2337f0b3b255d6e1a568b7
>> Author: Vlad Buslov <vladbu@mellanox.com>
>> Date:   Mon Feb 11 10:55:38 2019 +0200
>>
>>     net: sched: protect filter_chain list with filter_chain_lock mutex
>
> I think you are right, this is the commit introduced the code
> that inserts the tp before fully initializing it. Please Cc Vlad
> for your v2, in case we blame a wrong commit here.
>
>
> BTW, it looks like cls_cgroup needs a same fix. Please audit
> other tc filters as well.
>
> Thanks!

Sorry for late response. This is indeed the offending commit that should
be referenced by fixes tag.

Thanks for fixing this, Matteo!

  reply	other threads:[~2019-05-03  9:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29 17:38 [PATCH net] cls_matchall: avoid panic when receiving a packet before filter set Matteo Croce
2019-04-30 21:24 ` Cong Wang
2019-05-01  9:27   ` Matteo Croce
2019-05-02  0:48     ` Cong Wang
2019-05-03  9:03       ` Vlad Buslov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-05-02  8:51 Matteo Croce
2019-05-02  8:54 ` Matteo Croce
2019-05-02 16:21   ` Cong Wang
2019-05-02 16:31 ` Cong Wang
2019-05-04  4:58 ` David Miller

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=vbf8svnq59y.fsf@mellanox.com \
    --to=vladbu@mellanox.com \
    --cc=davem@davemloft.net \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mcroce@redhat.com \
    --cc=netdev@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).