]> git.baikalelectronics.ru Git - kernel.git/commit
tun: Extend RTNL lock coverage over whole ioctl
authorHerbert Xu <herbert@gondor.apana.org.au>
Thu, 6 Aug 2009 14:22:44 +0000 (14:22 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 10 Aug 2009 04:45:35 +0000 (21:45 -0700)
commit2d32ec614c38506e4f4c341a39ad0dbc1bcb4909
tree62959754494fb97f48d7c4f811d913321b046554
parentd3c7eaee3b9a3fb16bca1cc58aea823c3937d742
tun: Extend RTNL lock coverage over whole ioctl

As it is, parts of the ioctl runs under the RTNL and parts of
it do not.  The unlocked section is still protected by the BKL,
but there can be subtle races.  For example, Eric Biederman and
Paul Moore observed that if two threads tried to create two tun
devices on the same file descriptor, then unexpected results
may occur.

As there isn't anything in the ioctl that is expected to sleep
indefinitely, we can prevent this from occurring by extending
the RTNL lock coverage.

This also allows to get rid of the BKL.

Finally, I changed tun_get_iff to take a tun device in order to
avoid calling tun_put which would dead-lock as it also tries to
take the RTNL lock.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c