bridge: stp: Fix a potential use-after-free when deleting a bridge
Subsystems (3)
Ido Schimmel
maintainerPATCH 1/1 bridge: stp: Fix a potential use-after-free when deleting a bridge
The three STP timers are not supposed to be armed while the bridge is administratively down. They are synchronously deactivated when the bridge is put administratively down and the various call sites check for 'IFF_UP' before arming them.
This check is missing from br_topology_change_detection() and it is possible to engineer a situation in which the topology change timer is armed while the bridge is administratively down, resulting in a use-after-free [1] when the bridge is deleted.
Fix by adding the missing check and for good measures synchronously shutdown the three timers when the bridge is deleted.
[1]
ODEBUG: free active (active state 0) object: ffff88811662b9b0 object type: timer_list hint: br_topology_change_timer_expired (net/bridge/br_stp_timer.c:120)
WARNING: lib/debugobjects.c:629 at debug_print_object+0x1bc/0x450, CPU#9: ip/359
--- net/bridge/br_if.c | 3 +++ net/bridge/br_stp.c | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-)
net/bridge/br_if.c +3 -0
@@ -392,6 +392,9 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)br_fdb_delete_by_port (br,NULL ,0 ,1 ); +timer_shutdown_sync (&br->hello_timer); +timer_shutdown_sync (&br->topology_change_timer); +timer_shutdown_sync (&br->tcn_timer);cancel_delayed_work_sync (&br->gc_work);br_sysfs_delbr (br->dev);
net/bridge/br_stp.c +2 -1
@@ -382,7 +382,8 @@ void br_topology_change_detection(struct net_bridge *br) {int isroot =br_is_root_bridge (br); -if (br->stp_enabled !=BR_KERNEL_STP ) +if (br->stp_enabled !=BR_KERNEL_STP || + !(br->dev->flags &IFF_UP ))return ; br_info(br, "topology change detected, %s\n",
Signature · 1 line
2.54.0
Quoted 15 lines · Ido Schimmel
The three STP timers are not supposed to be armed while the bridge is administratively down. They are synchronously deactivated when the bridge is put administratively down and the various call sites check for '
IFF_UP' before arming them.This check is missing from
br_topology_change_detection()and it is possible to engineer a situation in which the topology change timer is armed while the bridge is administratively down, resulting in a use-after-free [1] when the bridge is deleted.Fix by adding the missing check and for good measures synchronously shutdown the three timers when the bridge is deleted.
[1]
ODEBUG: free active (active state 0) object:ffff88811662b9b0object type:timer_listhint:br_topology_change_timer_expired(net/bridge/br_stp_timer.c:120)
Quoted 7 lines
WARNING: lib/debugobjects.c:629 at debug_print_object+0x1bc/0x450, CPU#9: ip/359Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by Noam Rathaus <[email protected]>Reported-by Neil Young <[email protected]>Signed-off-by Ido Schimmel <[email protected]>
Quoted 15 lines · Ido Schimmel
The three STP timers are not supposed to be armed while the bridge is administratively down. They are synchronously deactivated when the bridge is put administratively down and the various call sites check for '
IFF_UP' before arming them.This check is missing from
br_topology_change_detection()and it is possible to engineer a situation in which the topology change timer is armed while the bridge is administratively down, resulting in a use-after-free [1] when the bridge is deleted.Fix by adding the missing check and for good measures synchronously shutdown the three timers when the bridge is deleted.
[1]
ODEBUG: free active (active state 0) object:ffff88811662b9b0object type:timer_listhint:br_topology_change_timer_expired(net/bridge/br_stp_timer.c:120)
Quoted 7 lines
WARNING: lib/debugobjects.c:629 at debug_print_object+0x1bc/0x450, CPU#9: ip/359Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")Reported-by Noam Rathaus <[email protected]>Reported-by Neil Young <[email protected]>Signed-off-by Ido Schimmel <[email protected]>
The PW bot is on holiday, no automated notifications for a while.
Applied, thanks!
/P