Skip to content

Commit c98cc00

Browse files
f6bvpgregkh
authored andcommitted
rose: fix notifier unregistered too early in rose_exit()
commit f71a8a1edc14dba746edde38adddd654ba202b4d upstream. rose_exit() called unregister_netdevice_notifier() before the loop that calls unregister_netdev() on each ROSE virtual device. As a result, the NETDEV_DOWN event fired by unregister_netdev() was never delivered to rose_device_event(), so rose_kill_by_device() never ran. Every socket whose rose->device pointed at a ROSE device therefore kept its netdev_tracker entry live until free_netdev() destroyed the ref_tracker_dir, at which point the kernel reported all of them as leaked references (165 entries in a typical FPAC setup). Worse, those sockets retained stale device pointers and live timers that could fire into freed module text after module unload, causing a silent system freeze with no kernel panic logged. Fix by moving unregister_netdevice_notifier() to after the device- unregistration loop. unregister_netdev() then delivers NETDEV_DOWN while the notifier is still registered, rose_kill_by_device() runs for each device, releases all netdev references held by open sockets, and calls rose_disconnect() which stops the per-socket timers. Signed-off-by: Bernard Pidoux <bernard.f6bvp@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1913902 commit c98cc00

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

net/rose/af_rose.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,19 +1669,28 @@ static void __exit rose_exit(void)
16691669
#ifdef CONFIG_SYSCTL
16701670
rose_unregister_sysctl();
16711671
#endif
1672-
unregister_netdevice_notifier(&rose_dev_notifier);
1673-
16741672
sock_unregister(PF_ROSE);
16751673

16761674
for (i = 0; i < rose_ndevs; i++) {
16771675
struct net_device *dev = dev_rose[i];
16781676

16791677
if (dev) {
1678+
/* unregister_netdev() fires NETDEV_DOWN, which -- while the
1679+
* notifier is still registered below -- invokes
1680+
* rose_kill_by_device(dev). That releases every socket's
1681+
* netdev reference and disconnects all active circuits.
1682+
* Unregistering the notifier before this loop was the
1683+
* original bug: NETDEV_DOWN was never delivered, leaving
1684+
* 165 netdev_tracker entries leaked and stale timers live.
1685+
*/
16801686
unregister_netdev(dev);
16811687
free_netdev(dev);
16821688
}
16831689
}
16841690

1691+
/* Now safe to remove the notifier -- all ROSE devices are gone. */
1692+
unregister_netdevice_notifier(&rose_dev_notifier);
1693+
16851694
kfree(dev_rose);
16861695
proto_unregister(&rose_proto);
16871696
}

0 commit comments

Comments
 (0)