Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jakub Kicinski <jakub.kicinski@netronome.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Eric Dumazet <eric.dumazet@gmail.com>
Cc: Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>,
	netdev <netdev@vger.kernel.org>,
	syzbot <syzkaller@googlegroups.com>,
	Vlad Buslov <vladbu@mellanox.com>, Jiri Pirko <jiri@mellanox.com>
Subject: Re: [PATCH net] net: sched: fix possible crash in tcf_action_destroy()
Date: Mon, 23 Sep 2019 08:44:52 -0700	[thread overview]
Message-ID: <4e2ff069-e1f5-492f-14eb-5348e2cab907@gmail.com> (raw)
In-Reply-To: <20190921190800.3f19fe23@cakuba.netronome.com>



On 9/21/19 7:08 PM, Jakub Kicinski wrote:
> On Wed, 18 Sep 2019 14:37:21 -0700, Cong Wang wrote:
>> On Wed, Sep 18, 2019 at 12:57 PM 'Eric Dumazet' via syzkaller
>> <syzkaller@googlegroups.com> wrote:
>>>
>>> If the allocation done in tcf_exts_init() failed,
>>> we end up with a NULL pointer in exts->actions.  
>> ...
>>> diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>>> index efd3cfb80a2ad775dc8ab3c4900bd73d52c7aaad..9aef93300f1c11791acbb9262dfe77996872eafe 100644
>>> --- a/net/sched/cls_api.c
>>> +++ b/net/sched/cls_api.c
>>> @@ -3027,8 +3027,10 @@ static int tc_dump_chain(struct sk_buff *skb, struct netlink_callback *cb)
>>>  void tcf_exts_destroy(struct tcf_exts *exts)
>>>  {
>>>  #ifdef CONFIG_NET_CLS_ACT
>>> -       tcf_action_destroy(exts->actions, TCA_ACT_UNBIND);
>>> -       kfree(exts->actions);
>>> +       if (exts->actions) {  
>>
>> I think it is _slightly_ better to check exts->nr_actions!=0 here,
>> as it would help exts->actions!=NULL&& exts->nr_actions==0
>> cases too.
>>
>> What do you think?
> 
> Alternatively, since tcf_exts_destroy() now takes NULL, and so
> obviously does kfree() - perhaps tcf_action_destroy() should 
> return early if actions are NULL?
> 

I do not have any preference really, this is slow path and was trying to
fix a crash.

tcf_action_destroy() makes me nervous, since it seems to be able to break its loop
in case __tcf_idr_release() returns an error. This means that some actions will
never be release.

  reply	other threads:[~2019-09-23 15:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-18 19:57 [PATCH net] net: sched: fix possible crash in tcf_action_destroy() Eric Dumazet
2019-09-18 21:37 ` Cong Wang
2019-09-22  2:08   ` Jakub Kicinski
2019-09-23 15:44     ` Eric Dumazet [this message]
2019-09-23 21:10       ` Cong Wang
2019-09-24 14:36 ` 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=4e2ff069-e1f5-492f-14eb-5348e2cab907@gmail.com \
    --to=eric.dumazet@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzkaller@googlegroups.com \
    --cc=vladbu@mellanox.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