Patch "net: bonding: correctly annotate RCU in bond_should_notify_peers()" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: bonding: correctly annotate RCU in bond_should_notify_peers()

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-bonding-correctly-annotate-rcu-in-bond_should_no.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 11c75a7c897a4c38082ae2a8fb38a7eaa517d07d
Author: Johannes Berg <johannes.berg@xxxxxxxxx>
Date:   Fri Jul 19 09:41:18 2024 -0700

    net: bonding: correctly annotate RCU in bond_should_notify_peers()
    
    [ Upstream commit 3ba359c0cd6eb5ea772125a7aededb4a2d516684 ]
    
    RCU use in bond_should_notify_peers() looks wrong, since it does
    rcu_dereference(), leaves the critical section, and uses the
    pointer after that.
    
    Luckily, it's called either inside a nested RCU critical section
    or with the RTNL held.
    
    Annotate it with rcu_dereference_rtnl() instead, and remove the
    inner RCU critical section.
    
    Fixes: 4cb4f97b7e36 ("bonding: rebuild the lock use for bond_mii_monitor()")
    Reviewed-by: Jiri Pirko <jiri@xxxxxxxxxx>
    Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
    Acked-by: Jay Vosburgh <jv@xxxxxxxxxxxxx>
    Link: https://patch.msgid.link/20240719094119.35c62455087d.I68eb9c0f02545b364b79a59f2110f2cf5682a8e2@changeid
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 34880b2db8050..722ac5c4992c9 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1121,13 +1121,10 @@ static struct slave *bond_find_best_slave(struct bonding *bond)
 	return bestslave;
 }
 
+/* must be called in RCU critical section or with RTNL held */
 static bool bond_should_notify_peers(struct bonding *bond)
 {
-	struct slave *slave;
-
-	rcu_read_lock();
-	slave = rcu_dereference(bond->curr_active_slave);
-	rcu_read_unlock();
+	struct slave *slave = rcu_dereference_rtnl(bond->curr_active_slave);
 
 	if (!slave || !bond->send_peer_notif ||
 	    bond->send_peer_notif %




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux