Skip to contentSkip to conversation

net: tun: unlink NAPI from device on destruction

PATCH Applied Jakub Kicinski 2 participants 2 messages Jun 23, 2022 – Jun 24, 2022

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: tun: unlink NAPI from device on destruction

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 [email protected]

---
CC: [email protected]
CC: [email protected]

---
 drivers/net/tun.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/tun.c +1 -0
index 87a635aac008..7fd0288c3789 100644
@@ -727,6 +727,7 @@ static void tun_detach_all(struct net_device *dev)
 		sock_put(&tfile->sk);
 	}
 	list_for_each_entry_safe(tfile, tmp, &tun->disabled, next) {
+		tun_napi_del(tfile);
 		tun_enable_queue(tfile);
 		tun_queue_purge(tfile);
 		xdp_rxq_info_unreg(&tfile->xdp_rxq);
Signature · 1 line
2.36.1
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 22 Jun 2022 21:20:39 -0700 you wrote:

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 [email protected]

[...]

Here is the summary with links:
- [net] net: tun: unlink NAPI from device on destruction

    https://git.kernel.org/netdev/net/c/3b9bc84d3111

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html