net ax25: Reorder ax25_exit to remove races.
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 18 Apr 2012 16:11:23 +0000 (16:11 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Fri, 11 May 2012 12:14:27 +0000 (13:14 +0100)
commit8629ca8e378bf28312de1674d3a610b75e35fb18
treefefb5af593e9c92720f0d8f53fb61a311df97127
parent427b96e9f08f7b44d83ef695930813f3fa8dfca3
net ax25: Reorder ax25_exit to remove races.

[ Upstream commit 3adadc08cc1e2cbcc15a640d639297ef5fcb17f5 ]

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.

Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
net/ax25/af_ax25.c