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:   Tue, 23 Apr 2019 09:31:49 -0700
From:   Wei Wang <weiwan@...gle.com>
To:     Eric Dumazet <edumazet@...gle.com>
Cc:     "David S . Miller" <davem@...emloft.net>,
        netdev <netdev@...r.kernel.org>,
        Eric Dumazet <eric.dumazet@...il.com>
Subject: Re: [PATCH net-next 2/3] ipv6: broadly use fib6_info_hold() helper

On Mon, Apr 22, 2019 at 6:35 PM Eric Dumazet <edumazet@...gle.com> wrote:
>
> Instead of using atomic_inc(), prefer fib6_info_hold()
> so that upcoming refcount_t conversion is simpler.
>
> Only fib6_info_alloc() is using atomic_set() since we
> just allocated a new object.
>
> Signed-off-by: Eric Dumazet <edumazet@...gle.com>
> Cc: Wei Wang <weiwan@...gle.com>
> ---

Acked-by: Wei Wang <weiwan@...gle.com>

>  net/ipv6/ip6_fib.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c
> index 55193859152969794dab3df02637217a7f21016f..a5e83593e0e45c2762eca85d04757f9d8e118e0f 100644
> --- a/net/ipv6/ip6_fib.c
> +++ b/net/ipv6/ip6_fib.c
> @@ -162,7 +162,7 @@ struct fib6_info *fib6_info_alloc(gfp_t gfp_flags)
>         }
>
>         INIT_LIST_HEAD(&f6i->fib6_siblings);
> -       atomic_inc(&f6i->fib6_ref);
> +       atomic_set(&f6i->fib6_ref, 1);
>
>         return f6i;
>  }
> @@ -846,8 +846,8 @@ static struct fib6_node *fib6_add_1(struct net *net,
>
>                 RCU_INIT_POINTER(in->parent, pn);
>                 in->leaf = fn->leaf;
> -               atomic_inc(&rcu_dereference_protected(in->leaf,
> -                               lockdep_is_held(&table->tb6_lock))->fib6_ref);
> +               fib6_info_hold(rcu_dereference_protected(in->leaf,
> +                               lockdep_is_held(&table->tb6_lock)));
>
>                 /* update parent pointer */
>                 if (dir)
> @@ -942,7 +942,7 @@ static void fib6_purge_rt(struct fib6_info *rt, struct fib6_node *fn,
>                         struct fib6_info *new_leaf;
>                         if (!(fn->fn_flags & RTN_RTINFO) && leaf == rt) {
>                                 new_leaf = fib6_find_prefix(net, table, fn);
> -                               atomic_inc(&new_leaf->fib6_ref);
> +                               fib6_info_hold(new_leaf);
>
>                                 rcu_assign_pointer(fn->leaf, new_leaf);
>                                 fib6_info_release(rt);
> @@ -1108,7 +1108,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
>                         return err;
>
>                 rcu_assign_pointer(rt->fib6_next, iter);
> -               atomic_inc(&rt->fib6_ref);
> +               fib6_info_hold(rt);
>                 rcu_assign_pointer(rt->fib6_node, fn);
>                 rcu_assign_pointer(*ins, rt);
>                 if (!info->skip_notify)
> @@ -1136,7 +1136,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
>                 if (err)
>                         return err;
>
> -               atomic_inc(&rt->fib6_ref);
> +               fib6_info_hold(rt);
>                 rcu_assign_pointer(rt->fib6_node, fn);
>                 rt->fib6_next = iter->fib6_next;
>                 rcu_assign_pointer(*ins, rt);
> @@ -1278,7 +1278,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
>                         if (!sfn)
>                                 goto failure;
>
> -                       atomic_inc(&info->nl_net->ipv6.fib6_null_entry->fib6_ref);
> +                       fib6_info_hold(info->nl_net->ipv6.fib6_null_entry);
>                         rcu_assign_pointer(sfn->leaf,
>                                            info->nl_net->ipv6.fib6_null_entry);
>                         sfn->fn_flags = RTN_ROOT;
> @@ -1321,7 +1321,7 @@ int fib6_add(struct fib6_node *root, struct fib6_info *rt,
>                                 rcu_assign_pointer(fn->leaf,
>                                             info->nl_net->ipv6.fib6_null_entry);
>                         } else {
> -                               atomic_inc(&rt->fib6_ref);
> +                               fib6_info_hold(rt);
>                                 rcu_assign_pointer(fn->leaf, rt);
>                         }
>                 }
> --
> 2.21.0.593.g511ec345e18-goog
>

Powered by blists - more mailing lists