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  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:   Thu, 22 Dec 2022 10:39:54 +0100
From:   Paolo Abeni <>
To:     Hangbin Liu <>,
        Eric Dumazet <>
Cc:     "David S . Miller" <>,
        Jakub Kicinski <>,,, syzbot <>,
        Jay Vosburgh <>,
        Veaceslav Falico <>,
        Andy Gospodarek <>
Subject: Re: [PATCH net] bonding: fix lockdep splat in bond_miimon_commit()

On Wed, 2022-12-21 at 11:33 +0800, Hangbin Liu wrote:
> Another questions is, I'm still a little confused with the mixing usage of
> rcu_access_pointer() and rtnl_dereference() under RTNL. e.g.
> In bond_miimon_commit() we use rcu_access_pointer() to check the pointers.
>                 case BOND_LINK_DOWN:
>                         if (slave == rcu_access_pointer(bond->curr_active_slave))
>                                 do_failover = true;
> In bond_ab_arp_commit() we use rtnl_dereference() to check the pointer
>                 case BOND_LINK_DOWN:
>                         if (slave == rtnl_dereference(bond->curr_active_slave)) {
>                                 RCU_INIT_POINTER(bond->current_arp_slave, NULL);
>                                 do_failover = true;
>                         }
>                 case BOND_LINK_FAIL:
>                         if (rtnl_dereference(bond->curr_active_slave))
>                                 RCU_INIT_POINTER(bond->current_arp_slave, NULL);
> Does it matter to use which one? Should we change to rcu_access_pointer()
> if there is no dereference?

You can use rcu_access_pointer() every time the code does not actually
use the RCU pointer, just checks for NULL value.

rtnl_dereference() needs stronger guarantees (the caller must hold the
RTNL lock at call time). As such it adds additional lockdep-safety, and
should be preferred _when_ the call site meets the requirement.

In the above bond_miimon_commit() example the rcu_access_pointer()
could be replaced with rtnl_dereference() for extra safety and
consistency, but it will be mostly a cosmetic change.



Powered by blists - more mailing lists