]> git.baikalelectronics.ru Git - kernel.git/commit
tun: Fix unregister race
authorEric W. Biederman <ebiederm@aristanetworks.com>
Mon, 8 Jun 2009 07:44:31 +0000 (00:44 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 8 Jun 2009 07:44:31 +0000 (00:44 -0700)
commit803314d20ea465d3670061faf72e4a830ac5215c
treea3ee9afad29dd6e01d7fe36c45ec1cca8d052ab9
parent8dfa4ced81118881f82ed993f91078195854b2d0
tun: Fix unregister race

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>
drivers/net/tun.c