net: tun: unlink NAPI from device on destruction
authorJakub Kicinski <kuba@kernel.org>
Thu, 23 Jun 2022 04:20:39 +0000 (21:20 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 7 Jul 2022 15:53:25 +0000 (17:53 +0200)
commit8145f77d38de4f88b8a69e1463f5c09ba189d77c
tree4ff2ba801ced3f7ff1bdecbb7937d5302f63584c
parent1e2327ba0fe928e646e4c69d1fa08e506f7fc62d
net: tun: unlink NAPI from device on destruction

commit 3b9bc84d311104906d2b4995a9a02d7b7ddab2db upstream.

Syzbot found a race between tun file and device destruction.
NAPIs live in struct tun_file which can get destroyed before
the netdev so we have to del them explicitly. The current
code is missing deleting the NAPI if the queue was detached
first.

Fixes: 943170998b20 ("tun: enable NAPI for TUN/TAP driver")
Reported-by: syzbot+b75c138e9286ac742647@syzkaller.appspotmail.com
Link: https://lore.kernel.org/r/20220623042039.2274708-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/tun.c