From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Lance Richardson <lrichard@redhat.com>, netdev@vger.kernel.org
Cc: dsa@cumulusnetworks.com
Subject: Re: [PATCH net] ipv4: initialize flowi4_flags before calling fib_lookup()
Date: Wed, 23 Mar 2016 14:35:38 +0300 [thread overview]
Message-ID: <56F27F8A.7070102@cogentembedded.com> (raw)
In-Reply-To: <1458673017-3528-1-git-send-email-lrichard@redhat.com>
Hello.
On 3/22/2016 9:56 PM, 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 the entire fl4 structure, which will prevent
> similar issues as fields are added in the future by ensuring that
> all fields are initialized to zero unless explicitly initialized
> to another value.
>
> Fixes: 58189ca7b2741 ("net: Fix vti use case with oif in dst lookups")
> Suggested-by: David Ahern <dsa@cumulusnetworks.com>
> Signed-off-by: Lance Richardson <lrichard@redhat.com>
> ---
> net/ipv4/fib_frontend.c | 16 +++++++---------
> 1 file changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
> index 21add55..8a9246d 100644
> --- a/net/ipv4/fib_frontend.c
> +++ b/net/ipv4/fib_frontend.c
[...]
> @@ -296,14 +295,13 @@ __be32 fib_compute_spec_dst(struct sk_buff *skb)
>
> scope = RT_SCOPE_UNIVERSE;
> if (!ipv4_is_zeronet(ip_hdr(skb)->saddr)) {
> - fl4.flowi4_oif = 0;
> - fl4.flowi4_iif = LOOPBACK_IFINDEX;
> - fl4.daddr = ip_hdr(skb)->saddr;
> - fl4.saddr = 0;
> - fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos);
> - fl4.flowi4_scope = scope;
> - fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0;
> - fl4.flowi4_tun_key.tun_id = 0;
> + 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,
> + };
Need empty line after the declaration.
> if (!fib_lookup(net, &fl4, &res, 0))
> return FIB_RES_PREFSRC(net, res);
> } else {
MBR, Sergei
next prev parent reply other threads:[~2016-03-23 11:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-22 18:56 [PATCH net] ipv4: initialize flowi4_flags before calling fib_lookup() 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 [this message]
-- strict thread matches above, loose matches on Subject: below --
2016-03-22 15:31 Lance Richardson
2016-03-22 18:29 ` David Ahern
2016-03-22 18:41 ` Lance Richardson
2016-03-22 20:45 ` Cong Wang
2016-03-22 21:02 ` David Ahern
2016-03-22 21:10 ` Cong Wang
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=56F27F8A.7070102@cogentembedded.com \
--to=sergei.shtylyov@cogentembedded.com \
--cc=dsa@cumulusnetworks.com \
--cc=lrichard@redhat.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 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.