netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: matti.vaittinen@nsn.com
Cc: dborkman@redhat.com, netdev@vger.kernel.org, mlin@ss.pku.edu.cn
Subject: Re: [PATCH net] net: fib: fib6_add: fix potential NULL pointer dereference
Date: Wed, 11 Sep 2013 16:14:29 -0400 (EDT)	[thread overview]
Message-ID: <20130911.161429.1045792260139768799.davem@davemloft.net> (raw)
In-Reply-To: <522D69FF.9000001@nsn.com>

From: Matti Vaittinen <matti.vaittinen@nsn.com>
Date: Mon, 09 Sep 2013 09:26:07 +0300

> On 09/07/2013 10:35 PM, ext Hannes Frederic Sowa wrote:
>> On Sat, Sep 07, 2013 at 03:13:20PM +0200, Daniel Borkmann wrote:
>>> When the kernel is compiled with CONFIG_IPV6_SUBTREES, and we return
>>> with an error in fn = fib6_add_1(), then error codes are encoded into
>>> the return pointer e.g. ERR_PTR(-ENOENT). In such an error case, we
>>> write the error code into err and jump to out, hence enter the if(err)
>>> condition. Now, if CONFIG_IPV6_SUBTREES is enabled, we check for:
>>>
>>>    if (pn != fn && pn->leaf == rt)
>>>      ...
>>>    if (pn != fn && !pn->leaf && !(pn->fn_flags & RTN_RTINFO))
>>>      ...
>>>
>>> Since pn is NULL and fn is f.e. ERR_PTR(-ENOENT), then pn != fn
>>> evaluates to true and causes a NULL-pointer dereference on further
>>> checks on pn. Fix it, by setting both NULL in error case, so that
>>> pn != fn already evaluates to false and no further dereference
>>> takes place.
>>>
>>> This was first correctly implemented in 4a287eba2 ("IPv6 routing,
>>> NLM_F_* flag support: REPLACE and EXCL flags support, warn about
>>> missing CREATE flag"), but the bug got later on introduced by
>>> 188c517a0 ("ipv6: return errno pointers consistently for
>>> fib6_add_1()").
>>>
>>> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
>>> Cc: Lin Ming <mlin@ss.pku.edu.cn>
>>> Cc: Matti Vaittinen <matti.vaittinen@nsn.com>
>>> Cc: Hannes Frederic Sowa <hannes@stressinduktion.org>
>>
>> Full ACK!
>>
>> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
>>
> Acked-by: Matti Vaittinen <matti.vaittinen@nsn.com>

Applied, thanks everyone.

      reply	other threads:[~2013-09-11 20:14 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-07 13:13 [PATCH net] net: fib: fib6_add: fix potential NULL pointer dereference Daniel Borkmann
2013-09-07 19:35 ` Hannes Frederic Sowa
2013-09-09  6:26   ` Matti Vaittinen
2013-09-11 20:14     ` David Miller [this message]

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=20130911.161429.1045792260139768799.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=dborkman@redhat.com \
    --cc=matti.vaittinen@nsn.com \
    --cc=mlin@ss.pku.edu.cn \
    --cc=netdev@vger.kernel.org \
    /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).