[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20130911.161429.1045792260139768799.davem@davemloft.net>
Date: Wed, 11 Sep 2013 16:14:29 -0400 (EDT)
From: David Miller <davem@...emloft.net>
To: matti.vaittinen@....com
Cc: dborkman@...hat.com, netdev@...r.kernel.org, mlin@...pku.edu.cn
Subject: Re: [PATCH net] net: fib: fib6_add: fix potential NULL pointer
dereference
From: Matti Vaittinen <matti.vaittinen@....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@...hat.com>
>>> Cc: Lin Ming <mlin@...pku.edu.cn>
>>> Cc: Matti Vaittinen <matti.vaittinen@....com>
>>> Cc: Hannes Frederic Sowa <hannes@...essinduktion.org>
>>
>> Full ACK!
>>
>> Acked-by: Hannes Frederic Sowa <hannes@...essinduktion.org>
>>
> Acked-by: Matti Vaittinen <matti.vaittinen@....com>
Applied, thanks everyone.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists