From: Steffen Klassert <steffen.klassert@secunet.com>
To: Florian Westphal <fw@strlen.de>
Cc: <netdev@vger.kernel.org>, <dan.carpenter@oracle.com>
Subject: Re: [PATCH ipsec-next] xfrm: fix possible null deref in xfrm_init_tempstate
Date: Mon, 16 Jan 2017 14:24:09 +0100 [thread overview]
Message-ID: <20170116132409.GP3541@gauss.secunet.com> (raw)
In-Reply-To: <1484315714-4840-1-git-send-email-fw@strlen.de>
On Fri, Jan 13, 2017 at 02:55:14PM +0100, Florian Westphal wrote:
> Dan reports following smatch warning:
> net/xfrm/xfrm_state.c:659
> error: we previously assumed 'afinfo' could be null (see line 651)
>
> 649 struct xfrm_state_afinfo *afinfo = xfrm_state_afinfo_get_rcu(family);
> 651 if (afinfo)
> ...
> 658 }
> 659 afinfo->init_temprop(x, tmpl, daddr, saddr);
>
> I am resonably sure afinfo cannot be NULL here.
>
> xfrm_state4.c and state6.c are both part of ipv4/ipv6 (depends on
> CONFIG_XFRM, a boolean) but even if ipv6 is a module state6.c can't
> be removed (ipv6 lacks module_exit so it cannot be removed).
>
> The only callers for xfrm6_fini that leads to state backend unregister
> are error unwinding paths that can be called during ipv6 init function.
>
> So after ipv6 module is loaded successfully the state backend cannot go
> away anymore.
>
> The family value from policy lookup path is taken from dst_entry, so
> that should always be AF_INET(6).
>
> However, since this silences the warning and avoids readers of this
> code wondering about possible null deref it seems preferrable to
> be defensive and just add the old check back.
>
> Fixes: 711059b9752ad0 ("xfrm: add and use xfrm_state_afinfo_get_rcu")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Florian Westphal <fw@strlen.de>
Applied to ipsec-next, thanks!
prev parent reply other threads:[~2017-01-16 13:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-13 13:55 [PATCH ipsec-next] xfrm: fix possible null deref in xfrm_init_tempstate Florian Westphal
2017-01-16 13:24 ` Steffen Klassert [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=20170116132409.GP3541@gauss.secunet.com \
--to=steffen.klassert@secunet.com \
--cc=dan.carpenter@oracle.com \
--cc=fw@strlen.de \
--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).