[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAEA6p_Dwtt3+VGzsEJMof33EVDHXhZPnjqaY-7WG1X=vgRk=gg@mail.gmail.com>
Date: Thu, 31 Aug 2017 09:39:31 -0700
From: Wei Wang <weiwan@...gle.com>
To: Stefano Brivio <sbrivio@...hat.com>
Cc: "David S . Miller" <davem@...emloft.net>,
Linux Kernel Network Developers <netdev@...r.kernel.org>,
Sabrina Dubroca <sdubroca@...hat.com>
Subject: Re: [PATCH net] ipv4: Don't override return code from ip_route_input_noref()
> After ip_route_input() calls ip_route_input_noref(), another
> check on skb_dst() is done, but if this fails, we shouldn't
> override the return code from ip_route_input_noref(), as it
> could have been more specific (i.e. -EHOSTUNREACH).
>
> This also saves one call to skb_dst_force_safe() and one to
> skb_dst() in case the ip_route_input_noref() check fails.
>
> Reported-by: Sabrina Dubroca <sdubroca@...hat.com>
> Fixes: ad65a2f05695 ("ipv4: call dst_hold_safe() properly")
> Signed-off-by: Stefano Brivio <sbrivio@...hat.com>
Acked-by: Wei Wang <weiwan@...gle.com>
On Thu, Aug 31, 2017 at 9:11 AM, Stefano Brivio <sbrivio@...hat.com> wrote:
> After ip_route_input() calls ip_route_input_noref(), another
> check on skb_dst() is done, but if this fails, we shouldn't
> override the return code from ip_route_input_noref(), as it
> could have been more specific (i.e. -EHOSTUNREACH).
>
> This also saves one call to skb_dst_force_safe() and one to
> skb_dst() in case the ip_route_input_noref() check fails.
>
> Reported-by: Sabrina Dubroca <sdubroca@...hat.com>
> Fixes: ad65a2f05695 ("ipv4: call dst_hold_safe() properly")
> Signed-off-by: Stefano Brivio <sbrivio@...hat.com>
> ---
> include/net/route.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/include/net/route.h b/include/net/route.h
> index cb0a76d9dde1..1b09a9368c68 100644
> --- a/include/net/route.h
> +++ b/include/net/route.h
> @@ -189,10 +189,11 @@ static inline int ip_route_input(struct sk_buff *skb, __be32 dst, __be32 src,
>
> rcu_read_lock();
> err = ip_route_input_noref(skb, dst, src, tos, devin);
> - if (!err)
> + if (!err) {
> skb_dst_force_safe(skb);
> - if (!skb_dst(skb))
> - err = -EINVAL;
> + if (!skb_dst(skb))
> + err = -EINVAL;
> + }
> rcu_read_unlock();
>
> return err;
> --
> 2.9.4
>
Powered by blists - more mailing lists