mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-15 03:53:12 -05:00
net: bonding: add the READ_ONCE/WRITE_ONCE for outside lock accessing
Although operations on the variable send_peer_notif are already within a lock-protected critical section, there are cases where it is accessed outside the lock. Therefore, READ_ONCE() and WRITE_ONCE() should be added to it. Cc: Jay Vosburgh <jv@jvosburgh.net> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: Simon Horman <horms@kernel.org> Cc: Jonathan Corbet <corbet@lwn.net> Cc: Andrew Lunn <andrew+netdev@lunn.ch> Cc: Nikolay Aleksandrov <razor@blackwall.org> Cc: Hangbin Liu <liuhangbin@gmail.com> Cc: Jason Xing <kerneljasonxing@gmail.com> Signed-off-by: Tonghao Zhang <tonghao@bamaicloud.com> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com> Link: https://patch.msgid.link/c1dcc53442f4d0f67beb9e0a3e7a7a6a2c94c47f.1768709239.git.tonghao@bamaicloud.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
committed by
Paolo Abeni
parent
f1986b3a9f
commit
429208aab9
@@ -1204,8 +1204,9 @@ void bond_peer_notify_work_rearm(struct bonding *bond, unsigned long delay)
|
||||
/* Peer notify update handler. Holds only RTNL */
|
||||
static void bond_peer_notify_reset(struct bonding *bond)
|
||||
{
|
||||
bond->send_peer_notif = bond->params.num_peer_notif *
|
||||
max(1, bond->params.peer_notif_delay);
|
||||
WRITE_ONCE(bond->send_peer_notif,
|
||||
bond->params.num_peer_notif *
|
||||
max(1, bond->params.peer_notif_delay));
|
||||
}
|
||||
|
||||
static void bond_peer_notify_handler(struct work_struct *work)
|
||||
@@ -2832,7 +2833,7 @@ static void bond_mii_monitor(struct work_struct *work)
|
||||
|
||||
rcu_read_unlock();
|
||||
|
||||
if (commit || bond->send_peer_notif) {
|
||||
if (commit || READ_ONCE(bond->send_peer_notif)) {
|
||||
/* Race avoidance with bond_close cancel of workqueue */
|
||||
if (!rtnl_trylock()) {
|
||||
delay = 1;
|
||||
@@ -3787,7 +3788,7 @@ static void bond_activebackup_arp_mon(struct bonding *bond)
|
||||
should_notify_rtnl = bond_ab_arp_probe(bond);
|
||||
rcu_read_unlock();
|
||||
|
||||
if (bond->send_peer_notif || should_notify_rtnl) {
|
||||
if (READ_ONCE(bond->send_peer_notif) || should_notify_rtnl) {
|
||||
if (!rtnl_trylock()) {
|
||||
delta_in_ticks = 1;
|
||||
goto re_arm;
|
||||
|
||||
Reference in New Issue
Block a user