Skip to contentSkip to conversation

bonding: fix send_peer_notif leekage on rtnl lock congestion

PATCH In review Veaceslav Falico 2 participants 3 messages Aug 5, 2013 – Aug 6, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bonding: fix send_peer_notif leekage on rtnl lock congestion

In bond_mii_monitor()/bond_activebackup_arp_mon(), we verify if we have any notifications to be sent before trying to get the rtnl_trylock(), and if we have - we set should_notify_peers and withdraw a notification. However, if we fail the get the rtnl_trylock(), we don't send out any notification and don't put the notification back to bond->send_peer_notif.

Fix it by putting back the notification to send_peer_notif in case of rtnl_trylock() failure.

CC Jay Vosburgh <[email protected]>
CC Andy Gospodarek <[email protected]>
---
 drivers/net/bonding/bond_main.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +8 -2
index 5697043..fd92738 100644
@@ -2383,7 +2383,10 @@ void bond_mii_monitor(struct work_struct *work)
 		if (!rtnl_trylock()) {
 			read_lock(&bond->lock);
 			delay = 1;
-			should_notify_peers = false;
+			if (should_notify_peers) {
+				bond->send_peer_notif++;
+				should_notify_peers = false;
+			}
 			goto re_arm;
 		}
 
@@ -2999,7 +3002,10 @@ void bond_activebackup_arp_mon(struct work_struct *work)
 		if (!rtnl_trylock()) {
 			read_lock(&bond->lock);
 			delta_in_ticks = 1;
-			should_notify_peers = false;
+			if (should_notify_peers) {
+				bond->send_peer_notif++;
+				should_notify_peers = false;
+			}
 			goto re_arm;
 		}
 
Signature · 1 line
1.8.1.4
maintainer
#1 lore raw

From: Veaceslav Falico <[email protected]>
Date: Mon, 5 Aug 2013 21:47:33 +0200

drivers/net/bonding/bond_main.c void bond_activebackup_arp_mon(struct work_struct *work) · line 3006

Quoted 7 lines
drivers/net/bonding/bond_main.c +2 -1
@@ -2999,7 +3002,10 @@ void bond_activebackup_arp_mon(struct work_struct *work)
 		if (!rtnl_trylock()) {
 			read_lock(&bond->lock);
 			delta_in_ticks = 1;
-			should_notify_peers = false;
+			if (should_notify_peers) {
+				bond->send_peer_notif++;

I doubt this increment to a shared datastructure is safe with the locks you hold here.

You don't hold RTNL and you only have bond->lock as a reader.

#2 lore raw
Quoted 14 lines · David Miller

From: Veaceslav Falico <[email protected]>
Date: Mon, 5 Aug 2013 21:47:33 +0200

drivers/net/bonding/bond_main.c void bond_activebackup_arp_mon(struct work_struct *work) · line 3006

Quoted 7 lines
drivers/net/bonding/bond_main.c +2 -1
@@ -2999,7 +3002,10 @@ void bond_activebackup_arp_mon(struct work_struct *work)
 		if (!rtnl_trylock()) {
 			read_lock(&bond->lock);
 			delta_in_ticks = 1;
-			should_notify_peers = false;
+			if (should_notify_peers) {
+				bond->send_peer_notif++;

I doubt this increment to a shared datastructure is safe with the locks you hold here.

Quoted 1 line

You don't hold RTNL and you only have bond->lock as a reader.

You're right, we can race here. This whole locking juggling should be changed.

Self-NAK for this, I'll rework it.