]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
tun: Fix unregister race
authorEric W. Biederman <ebiederm@aristanetworks.com>
Mon, 8 Jun 2009 07:44:31 +0000 (00:44 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Thu, 2 Jul 2009 23:49:42 +0000 (16:49 -0700)
commit71d1ad90a58e00cf8aebd0e6c579c105d2ecb697
treef4ce04934de37e3f8ade2532a6c4e0b5be8b2285
parent51058607814a1cde627d2878866f2aee6b99e8f1
tun: Fix unregister race

[ Upstream commit f0a4d0e5b5bfd271e6737f7c095994835b70d450 ]

It is possible for tun_chr_close to race with dellink on the
a tun device.  In which case if __tun_get runs before dellink
but dellink runs before tun_chr_close calls unregister_netdevice
we will attempt to unregister the netdevice after it is already
gone.

The two cases are already serialized on the rtnl_lock, so I have
gone for the cheap simple fix of moving rtnl_lock to cover __tun_get
in tun_chr_close.  Eliminating the possibility of the tun device
being unregistered between __tun_get and unregister_netdevice in
tun_chr_close.

Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Tested-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/net/tun.c