net ax25: Reorder ax25_exit to remove races.
Subsystems (2)
PATCH 1/1 net ax25: Reorder ax25_exit to remove races.
While reviewing the sysctl code in ax25 I spotted races in ax25_exit where it is possible to receive notifications and packets after already freeing up some of the data structures needed to process those notifications and updates.
Call unregister_netdevice_notifier early so that the rest of the cleanup code does not need to deal with network devices. This takes advantage of my recent enhancement to unregister_netdevice_notifier to send unregister notifications of all network devices that are current registered.
Move the unregistration for packet types, socket types and protocol types before we cleanup any of the ax25 data structures to remove the possibilities of other races.
--- net/ax25/af_ax25.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
net/ax25/af_ax25.c +5 -4
@@ -2011,16 +2011,17 @@ static void __exit ax25_exit(void)proc_net_remove (&init_net,"ax25_route" );proc_net_remove (&init_net,"ax25" );proc_net_remove (&init_net,"ax25_calls" ); -ax25_rt_free (); -ax25_uid_free (); -ax25_dev_free (); -ax25_unregister_sysctl ();unregister_netdevice_notifier (&ax25_dev_notifier); +ax25_unregister_sysctl ();dev_remove_pack (&ax25_packet_type);sock_unregister (PF_AX25 );proto_unregister (&ax25_proto); + +ax25_rt_free (); +ax25_uid_free (); +ax25_dev_free (); }module_exit (ax25_exit);
Signature · 1 line
1.7.2.5
From: [email protected] (Eric W. Biederman)
Date: Wed, 18 Apr 2012 19:11:23 -0700
Quoted 11 lines
While reviewing the sysctl code in ax25 I spotted races in
ax25_exitwhere it is possible to receive notifications and packets after already freeing up some of the data structures needed to process those notifications and updates.Call
unregister_netdevice_notifierearly so that the rest of the cleanup code does not need to deal with network devices. This takes advantage of my recent enhancement tounregister_netdevice_notifierto send unregister notifications of all network devices that are current registered.
Quoted 5 lines
Move the unregistration for packet types, socket types and protocol types before we cleanup any of the ax25 data structures to remove the possibilities of other races.
Signed-off-by Eric W. Biederman <[email protected]>
Applied, thanks a lot Eric.