net: tun: avoid disabling NAPI twice
Subsystems (4)
Jakub Kicinski
maintainerPATCH 1/2 net: tun: avoid disabling NAPI twice
Eric reports that syzbot made short work out of my speculative fix. Indeed when queue gets detached its tfile->tun remains, so we would try to stop NAPI twice with a detach(), close() sequence.
Alternative fix would be to move tun_napi_disable() to tun_detach_all() and let the NAPI run after the queue has been detached.
---
Cc: Petar Penkov <[email protected]>
---
CC: [email protected]
--- drivers/net/tun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/tun.c +2 -1
@@ -640,7 +640,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean) tun =rtnl_dereference (tfile->tun);if (tun && clean) { -tun_napi_disable (tfile); +if (!tfile->detached) +tun_napi_disable (tfile);tun_napi_del (tfile); }
Signature · 1 line
2.36.1
Jakub Kicinski
maintainerPATCH 2/2 selftest: tun: add test for NAPI dismantle
Being lazy does not pay, add the test for various
ordering of tun queue close / detach / destroy.
---
CC: [email protected]
CC: [email protected]
--- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tun.c | 162 +++++++++++++++++++++++++++ 2 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/net/tun.c
tools/testing/selftests/net/Makefile +1 -1
@@ -54,7 +54,7 @@ TEST_GEN_FILES += ipsec TEST_GEN_FILES += ioam6_parser TEST_GEN_FILES += gro TEST_GEN_PROGS = reuseport_bpf reuseport_bpf_cpu reuseport_bpf_numa -TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls +TEST_GEN_PROGS += reuseport_dualstack reuseaddr_conflict tls tun TEST_GEN_FILES += toeplitz TEST_GEN_FILES += cmsg_sender TEST_GEN_FILES += stress_reuseport_listen
tools/testing/selftests/net/tun.c new file +162 -0
162 lines not on this page · raw message
Signature · 1 line
2.36.1
Quoted 11 lines · Jakub Kicinski
Eric reports that syzbot made short work out of my speculative fix. Indeed when queue gets detached its
tfile->tunremains, so we would try to stop NAPI twice with adetach(),close()sequence.Alternative fix would be to move
tun_napi_disable()totun_detach_all()and let the NAPI run after the queue has been detached.Fixes a8fc8cb5692a ("net: tun: stop NAPI when detaching queues")
Quoted 28 lines
Reported-by syzbot <[email protected]>Reported-by Eric Dumazet <[email protected]>Signed-off-by Jakub Kicinski <[email protected]>---
Cc: Petar Penkov <[email protected]>
---
CC: [email protected]--- drivers/net/tun.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/tun.c +2
-2@@ -640,7 +640,8 @@ static void __tun_detach(struct tun_file *tfile, bool clean) tun =rtnl_dereference (tfile->tun);if (tun && clean) { -tun_napi_disable (tfile); +if (!tfile->detached) +tun_napi_disable (tfile);tun_napi_del (tfile); } --2.36.1
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Wed, 29 Jun 2022 11:19:10 -0700 you wrote:
Eric reports that syzbot made short work out of my speculative fix. Indeed when queue gets detached its
tfile->tunremains, so we would try to stop NAPI twice with adetach(),close()sequence.Alternative fix would be to move
tun_napi_disable()totun_detach_all()and let the NAPI run after the queue has been detached.[...]
Here is the summary with links:
- [net,1/2] net: tun: avoid disabling NAPI twice
https://git.kernel.org/netdev/net/c/ff1fa2081d17 - [net,2/2] selftest: tun: add test for NAPI dismantle https://git.kernel.org/netdev/net/c/839b92fede7b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html