net: fix a potential recursive NETDEV_FEAT_CHANGE
Subsystems (2)
PATCH v3 1/1 net: fix a potential recursive NETDEV_FEAT_CHANGE
syzbot managed to trigger a recursive NETDEV_FEAT_CHANGE event between bonding master and slave. I managed to find a reproducer for this:
ip li set bond0 up
ifenslave bond0 eth0
brctl addbr br0
ethtool -K eth0 lro off
brctl addif br0 bond0
ip li set br0 up
When a NETDEV_FEAT_CHANGE event is triggered on a bonding slave, it captures this and calls bond_compute_features() to fixup its master's and other slaves' features. However, when syncing with its lower devices by netdev_sync_lower_features() this event is triggered again on slaves when the LRO feature fails to change, so it goes back and forth recursively until the kernel stack is exhausted.
Commit 17b85d29e82c intentionally lets __netdev_update_features() return -1 for such a failure case, so we have to just rely on the existing check inside netdev_sync_lower_features() and skip NETDEV_FEAT_CHANGE event only for this specific failure case.
--- net/core/dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
net/core/dev.c +3 -1
@@ -8907,11 +8907,13 @@ static void netdev_sync_lower_features(struct net_device *upper,netdev_dbg (upper,"Disabling feature %pNF on lower dev %s.\n" , &feature, lower->name); lower->wanted_features &= ~feature; -netdev_update_features (lower); +__netdev_update_features (lower);if (unlikely (lower->features & feature))netdev_WARN (upper,"failed to disable %pNF on %s!\n" , &feature, lower->name); +else +netdev_features_change (lower); } } }
Signature · 1 line
2.26.2
Quoted 47 lines · Cong Wang
syzbot managed to trigger a recursive
NETDEV_FEAT_CHANGEevent between bonding master and slave. I managed to find a reproducer for this:ip li set bond0 up
ifenslave bond0 eth0
brctl addbr br0
ethtool -K eth0 lro off
brctl addif br0 bond0
ip li set br0 upWhen a
NETDEV_FEAT_CHANGEevent is triggered on a bonding slave, it captures this and callsbond_compute_features()to fixup its master's and other slaves' features. However, when syncing with its lower devices bynetdev_sync_lower_features()this event is triggered again on slaves when the LRO feature fails to change, so it goes back and forth recursively until the kernel stack is exhausted.Commit
17b85d29e82cintentionally lets__netdev_update_features()return -1 for such a failure case, so we have to just rely on the existing check insidenetdev_sync_lower_features()and skipNETDEV_FEAT_CHANGEevent only for this specific failure case.Fixes fd867d51f889 ("net/core: generic support for disabling netdev features down stack")Reported-by [email protected]Reported-by [email protected]Cc Jarod Wilson <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Cc Josh Poimboeuf <[email protected]>Cc Jann Horn <[email protected]>Reviewed-by Jay Vosburgh <[email protected]>Signed-off-by Cong Wang <[email protected]>--- net/core/dev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)net/core/dev.c +0
-1@@ -8907,11 +8907,13 @@ static void netdev_sync_lower_features(struct net_device *upper,netdev_dbg (upper,"Disabling feature %pNF on lower dev %s.\n" , &feature, lower->name); lower->wanted_features &= ~feature; -netdev_update_features (lower);
net/core/dev.c static void netdev_sync_lower_features(struct net_device *upper, · line 8919
Quoted 10 lines
net/core/dev.c +3
-0+__netdev_update_features (lower);if (unlikely (lower->features & feature))netdev_WARN (upper,"failed to disable %pNF on %s!\n" , &feature, lower->name); +else +netdev_features_change (lower); } } }
David Miller
maintainerFrom: Cong Wang <[email protected]>
Date: Thu, 7 May 2020 12:19:03 -0700
Quoted 24 lines
syzbot managed to trigger a recursive
NETDEV_FEAT_CHANGEevent between bonding master and slave. I managed to find a reproducer for this:ip li set bond0 up
ifenslave bond0 eth0
brctl addbr br0
ethtool -K eth0 lro off
brctl addif br0 bond0
ip li set br0 upWhen a
NETDEV_FEAT_CHANGEevent is triggered on a bonding slave, it captures this and callsbond_compute_features()to fixup its master's and other slaves' features. However, when syncing with its lower devices bynetdev_sync_lower_features()this event is triggered again on slaves when the LRO feature fails to change, so it goes back and forth recursively until the kernel stack is exhausted.Commit
17b85d29e82cintentionally lets__netdev_update_features()return -1 for such a failure case, so we have to just rely on the existing check insidenetdev_sync_lower_features()and skipNETDEV_FEAT_CHANGEevent only for this specific failure case.
Quoted 9 lines
Fixes fd867d51f889 ("net/core: generic support for disabling netdev features down stack")Reported-by [email protected]Reported-by [email protected]Cc Jarod Wilson <[email protected]>Cc Nikolay Aleksandrov <[email protected]>Cc Josh Poimboeuf <[email protected]>Cc Jann Horn <[email protected]>Reviewed-by Jay Vosburgh <[email protected]>Signed-off-by Cong Wang <[email protected]>
Applied and queued up for -stable, thanks Cong.