lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 20 Mar 2019 02:21:01 +0800
From:   Xin Long <lucien.xin@...il.com>
To:     David Ahern <dsa@...ulusnetworks.com>
Cc:     Paolo Abeni <pabeni@...hat.com>, Wei Wang <weiwan@...gle.com>,
        network dev <netdev@...r.kernel.org>,
        "David S . Miller" <davem@...emloft.net>
Subject: Re: [PATCH net] ipv6: make ip6_create_rt_rcu return ip6_null_entry
 instead of NULL

On Tue, Mar 19, 2019 at 10:04 PM David Ahern <dsa@...ulusnetworks.com> wrote:
>
> On 3/19/19 9:19 AM, Paolo Abeni wrote:
> > Hi,
> >
> > On Mon, 2019-03-18 at 14:30 -0700, Wei Wang wrote:
> >> On Mon, Mar 18, 2019 at 12:48 PM David Ahern <dsa@...ulusnetworks.com> wrote:
> >>> On 3/18/19 12:36 PM, Xin Long wrote:
> >>>> diff --git a/net/ipv6/route.c b/net/ipv6/route.c
> >>>> index 4ef4bbd..754777d 100644
> >>>> --- a/net/ipv6/route.c
> >>>> +++ b/net/ipv6/route.c
> >>>> @@ -1040,13 +1040,17 @@ static struct rt6_info *ip6_create_rt_rcu(struct fib6_info *rt)
> >>>>       struct rt6_info *nrt;
> >>>>
> >>>>       if (!fib6_info_hold_safe(rt))
> >>>> -             return NULL;
> >>>> +             goto fallback;
> >>>>
> >>>>       nrt = ip6_dst_alloc(dev_net(dev), dev, flags);
> >>>> -     if (nrt)
> >>>> +     if (nrt) {
> >>>>               ip6_rt_copy_init(nrt, rt);
> >>>> -     else
> >>>> +     } else {
> >>>>               fib6_info_release(rt);
> >>>> +fallback:
> >>>> +             nrt = dev_net(dev)->ipv6.ip6_null_entry;
> >>>> +             dst_hold(&nrt->dst);
> >>>> +     }
> >>>>
> >>>>       return nrt;
> >>>>  }
> >>>
> >>> It seems appropriate for ip6_create_rt_rcu to always return an rt6_info
> >>> given its use and v6 design. Since ip6_dst_alloc can also fail
> >>> (e.g.,
> >>> exceed gc_thresh) the fallback case should apply to both.
> >>
> >> Agree. We should take care of ip6_dst_alloc() as well.
> >
> > AFAICS, if ip6_dst_alloc() fails/returns a NULL ptr, with this patch we
> > do enter the fallback path (and return a valid rt6_info). I think your
> > concerns are already addressed, what I'm missing ?!?
> >
>
> you are correct. It should be made clearer from a readability perspective.
I will post v2 by moving down 'fallback:':

{ ...
        if (!fib6_info_hold_safe(rt))
                goto fallback;

        nrt = ip6_dst_alloc(dev_net(dev), dev, flags);
        if (!nrt) {
                fib6_info_release(rt);
                goto fallback;
        }

        ip6_rt_copy_init(nrt, rt);
        return nrt;

fallback:
        nrt = dev_net(dev)->ipv6.ip6_null_entry;
        dst_hold(&nrt->dst);
        return nrt;
}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ