All of lore.kernel.org
 help / color / mirror / Atom feed
From: Phil Sutter <phil@nwl.cc>
To: Martin KaFai Lau <kafai@fb.com>,
	netdev@vger.kernel.org,
	Hannes Frederic Sowa <hannes@stressinduktion.org>,
	Steffen Klassert <steffen.klassert@secunet.com>,
	Julian Anastasov <ja@ssi.bg>
Subject: Re: NULL pointer dereference in rt6_get_cookie()
Date: Tue, 13 Oct 2015 21:26:41 +0200	[thread overview]
Message-ID: <20151013192543.06B5021398@mail.nwl.cc> (raw)
In-Reply-To: <20151013191039.GA3070@base.sg13b.nwl.cc>

On Tue, Oct 13, 2015 at 09:10:39PM +0200, Phil Sutter wrote:
> Hi Martin,
> 
> On Tue, Oct 13, 2015 at 11:14:43AM -0700, Martin KaFai Lau wrote:
> > On Sat, Oct 10, 2015 at 03:24:37PM +0200, Phil Sutter wrote:
> > > The conditional at the start of the function evaluates true, since
> > > 'rt->rt6i_flags & RTF_PCPU' is non-zero.
> > Hi Phil, can you try the following patch and capture the dmesg output
> > to confirm the value of rt->rt6i_flags and the rt->dst.flags.
> > 
> > Thanks,
> > Martin
> > 
> > --- a/include/net/ip6_fib.h
> > +++ b/include/net/ip6_fib.h
> > @@ -167,8 +167,15 @@ static inline void rt6_update_expires(struct rt6_info *rt0, int timeout)
> > 
> >  static inline u32 rt6_get_cookie(const struct rt6_info *rt)
> >  {
> > -	if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE))
> > +	if (rt->rt6i_flags & RTF_PCPU || unlikely(rt->dst.flags & DST_NOCACHE)) {
> >  		rt = (struct rt6_info *)(rt->dst.from);
> > +		if (!rt)
> > +			pr_err("rt6i_dst:%pI6c/%d rt6i_gateway:%pI6c "
> > +			       "rt6i_flags:%08X dst.flags:%08X\n",
> > +			       &rt->rt6i_dst.addr, rt->rt6i_dst.plen,
> > +			       &rt->rt6i_gateway, rt->rt6i_flags,
> > +			       rt->dst.flags);
> > +	}
> > 
> >  	return rt->rt6i_node ? rt->rt6i_node->fn_sernum : 0;
> >  }
> 
> This code is not sane. Your pr_err() statement tries to dereference the
> NULL pointer in question. Are you interested in the originally passed
> rt6_info?

I have backed up the rt pointer at top of the function and restored it
before pr_err, this is the output:

| rt6i_dst:2001:4dd0:ff3b:13::/64 rt6i_gateway::: rt6i_flags:40000001 dst.flags:00000000

HTH, Phil

  parent reply	other threads:[~2015-10-13 19:25 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-10 13:24 NULL pointer dereference in rt6_get_cookie() Phil Sutter
2015-10-12 20:31 ` Martin KaFai Lau
2015-10-13 18:14 ` Martin KaFai Lau
2015-10-13 19:10   ` Phil Sutter
2015-10-13 19:30     ` Martin KaFai Lau
     [not found]   ` <20151013191039.GA3070@base.sg13b.nwl.cc>
2015-10-13 19:26     ` Phil Sutter [this message]
2015-10-14  6:14       ` Martin KaFai Lau
2015-10-14 22:34         ` Phil Sutter
2015-10-14 23:17           ` Martin KaFai Lau

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=20151013192543.06B5021398@mail.nwl.cc \
    --to=phil@nwl.cc \
    --cc=hannes@stressinduktion.org \
    --cc=ja@ssi.bg \
    --cc=kafai@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=steffen.klassert@secunet.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.