netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Davide Caratti <dcaratti@redhat.com>
To: Eric Dumazet <edumazet@google.com>,
	"David S . Miller" <davem@davemloft.net>
Cc: netdev <netdev@vger.kernel.org>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	syzbot <syzkaller@googlegroups.com>
Subject: Re: [PATCH net] net/sched: act_ife: initalize ife->metalist earlier
Date: Wed, 15 Jan 2020 10:14:19 +0100	[thread overview]
Message-ID: <7b6aad5de9b62323f0a8b24ce2d5c7d5adcd89b4.camel@redhat.com> (raw)
In-Reply-To: <20200114215128.87537-1-edumazet@google.com>

On Tue, 2020-01-14 at 13:51 -0800, Eric Dumazet wrote:
> It seems better to init ife->metalist earlier in tcf_ife_init()
> to avoid the following crash :

hello Eric, and thanks for the patch.

If I well understand the problem, we have

_tcf_ife_cleanup()

that does dereference of NULL ife->metalist,
because it has not yet initialized by tcf_ife_init(). This happened
probably because the control action was not valid (hence the Fixes:tag):
so, tcf_ife_init() jumped to the error path before doing INIT_LIST_HEAD().

I applied your patch to my tree, and I see this:

net/sched/act_ife.c: In function 'tcf_ife_init':
net/sched/act_ife.c:533:3: warning: 'ife' may be used uninitialized in
this function [-Wmaybe-uninitialized]
   INIT_LIST_HEAD(&ife->metalist);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And I think the warning is telling us a real problem, because

        ife = to_ife(*a);

is done below the if (!exists) { } statement where you are dereferencing
'ife'.

I think the proper fix should do one of these two things:
1) ensure that 'ife' is a valid pointer in the INIT_LIST_HEAD()
2) leave tcf_ife_init() as is, and fix the priblem in _tcf_ife_clenup() by
proper checking the value of ife->metalist  (which should be NULL in the
error path, because tcf_idr_create() does kzalloc() [1].
WDYT?

thanks!
-- 
davide

[1] https://elixir.bootlin.com/linux/latest/source/net/sched/act_api.c#L404



  reply	other threads:[~2020-01-15  9:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14 21:51 [PATCH net] net/sched: act_ife: initalize ife->metalist earlier Eric Dumazet
2020-01-15  9:14 ` Davide Caratti [this message]
2020-01-15 15:56   ` Eric Dumazet

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=7b6aad5de9b62323f0a8b24ce2d5c7d5adcd89b4.camel@redhat.com \
    --to=dcaratti@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=syzkaller@googlegroups.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).