netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lance Richardson <lrichard@redhat.com>
To: David Ahern <dsa@cumulusnetworks.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH net] ipv4: initialize flowi4_flags before calling fib_lookup()
Date: Tue, 22 Mar 2016 14:41:48 -0400 (EDT)	[thread overview]
Message-ID: <950377980.72657238.1458672108040.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <56F18EEE.4070000@cumulusnetworks.com>

----- Original Message -----
> From: "David Ahern" <dsa@cumulusnetworks.com>
> To: "Lance Richardson" <lrichard@redhat.com>, netdev@vger.kernel.org
> Sent: Tuesday, March 22, 2016 2:29:02 PM
> Subject: Re: [PATCH net] ipv4: initialize flowi4_flags before calling fib_lookup()
> 
> On 3/22/16 9:31 AM, Lance Richardson wrote:
> > Field fl4.flowi4_flags is not initialized in fib_compute_spec_dst()
> > before calling fib_lookup(), which means fib_table_lookup() is
> > using non-deterministic data at this line:
> >
> > 	if (!(flp->flowi4_flags & FLOWI_FLAG_SKIP_NH_OIF)) {
> >
> > Fix by initializing fl4.flowi4_flags to zero.
> >
> > Signed-off-by: Lance Richardson <lrichard@redhat.com>
> > ---
> >   net/ipv4/fib_frontend.c | 1 +
> >   1 file changed, 1 insertion(+)
> >
> > diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> > index 21add55..896844a 100644
> > --- a/net/ipv4/fib_frontend.c
> > +++ b/net/ipv4/fib_frontend.c
> > @@ -304,6 +304,7 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
> >   		fl4.flowi4_scope = scope;
> >   		fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0;
> >   		fl4.flowi4_tun_key.tun_id = 0;
> > +		fl4.flowi4_flags = 0;
> >   		if (!fib_lookup(net, &fl4, &res, 0))
> >   			return FIB_RES_PREFSRC(net, res);
> >   	} else {
> >
> 
> Fixes: 58189ca7b2741 ("net: Fix vti use case with oif in dst lookups")
> 
> I think a more robust solution is to move fl4 to this if case and init
> when it is declared:
> 
> 	struct flowi4 fl4 = {
> 		.flowi4_iif = LOOPBACK_IFINDEX,
> 		.daddr = ip_hdr(skb)->saddr,
> 		.flowi4_tos = RT_TOS(ip_hdr(skb)->tos),
> 		.flowi4_scope = scope,
> 		.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0,
> 	};
> 

Agreed... I actually debated doing something similar but opted for the
smaller delta.

v2 coming up.

Thanks for the review,

   Lance

  reply	other threads:[~2016-03-22 18:41 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 15:31 [PATCH net] ipv4: initialize flowi4_flags before calling fib_lookup() Lance Richardson
2016-03-22 18:29 ` David Ahern
2016-03-22 18:41   ` Lance Richardson [this message]
2016-03-22 20:45   ` Cong Wang
2016-03-22 21:02     ` David Ahern
2016-03-22 21:10       ` Cong Wang
  -- strict thread matches above, loose matches on Subject: below --
2016-03-22 18:56 Lance Richardson
2016-03-22 18:58 ` Lance Richardson
2016-03-22 20:03   ` David Miller
2016-03-22 19:00 ` David Ahern
2016-03-22 20:15   ` Eric Dumazet
2016-03-23 11:35 ` Sergei Shtylyov

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=950377980.72657238.1458672108040.JavaMail.zimbra@redhat.com \
    --to=lrichard@redhat.com \
    --cc=dsa@cumulusnetworks.com \
    --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).