syzbot


panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint

Status: fixed on 2025/09/17 00:02
Fix commit: 20452a237b48 net/tun: Do not DecRef a closed TUN endpoint when un-persisting it.
First crash: 174d, last: 173d

Sample crash report:
panic: Decrementing non-positive ref count 0xc0006a6000, owned by tun.tunEndpoint

goroutine 669 gp=0xc00123ee00 m=24 mp=0xc000750808 [running]:
panic({0x1cd9300?, 0xc001a8e0f0?})
	GOROOT/src/runtime/panic.go:811 +0x168 fp=0xc000f0f310 sp=0xc000f0f260 pc=0x47d728
gvisor.dev/gvisor/pkg/tcpip/link/tun.(*tunEndpointRefs).DecRef(0xc0006a6000, 0xc000f0f398)
	bazel-out/k8-fastbuild/bin/pkg/tcpip/link/tun/tun_endpoint_refs.go:127 +0x179 fp=0xc000f0f388 sp=0xc000f0f310 pc=0x1235159
gvisor.dev/gvisor/pkg/tcpip/link/tun.(*tunEndpoint).DecRef(0xc0006a6000, {0xc00147a260?, 0x457b27?})
	pkg/tcpip/link/tun/device.go:415 +0x6a fp=0xc000f0f3b8 sp=0xc000f0f388 pc=0x1233a0a
gvisor.dev/gvisor/pkg/tcpip/link/tun.(*Device).Release(0xc000fb0068, {0x21b8bb0, 0xc0008c5908})
	pkg/tcpip/link/tun/device.go:98 +0x1a6 fp=0xc000f0f440 sp=0xc000f0f3b8 pc=0x1230bc6
gvisor.dev/gvisor/pkg/sentry/devices/tundev.(*tunFD).Release(0xc000fb0000, {0x21b8bb0, 0xc0008c5908})
	pkg/sentry/devices/tundev/tundev.go:127 +0x52 fp=0xc000f0f468 sp=0xc000f0f440 pc=0x17d8bb2
gvisor.dev/gvisor/pkg/sentry/vfs.(*FileDescription).DecRef.func1()
	pkg/sentry/vfs/file_description.go:205 +0x55c fp=0xc000f0f5a8 sp=0xc000f0f468 pc=0xb5657c
gvisor.dev/gvisor/pkg/sentry/vfs.(*FileDescriptionRefs).DecRef(0xc000fb0000, 0xc000f0f630)
	bazel-out/k8-fastbuild/bin/pkg/sentry/vfs/file_description_refs.go:133 +0xb4 fp=0xc000f0f620 sp=0xc000f0f5a8 pc=0xb618d4
gvisor.dev/gvisor/pkg/sentry/vfs.(*FileDescription).DecRef(0xc000fb0000, {0x21b8bb0, 0xc0008c5908})
	pkg/sentry/vfs/file_description.go:161 +0xa5 fp=0xc000f0f660 sp=0xc000f0f620 pc=0xb55fe5
gvisor.dev/gvisor/pkg/sentry/syscalls/linux.CloseRange(0xc0008c5908, 0x457b27?, {{0x3}, {0x1e}, {0x0}, {0x55f1b335dcb0}, {0x0}, {0x7c479a9ef}})
	pkg/sentry/syscalls/linux/sys_file.go:504 +0x3e7 fp=0xc000f0f6e8 sp=0xc000f0f660 pc=0x12c7f47
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).executeSyscall(0xc0008c5908, 0x1b4, {{0x3}, {0x1e}, {0x0}, {0x55f1b335dcb0}, {0x0}, {0x7c479a9ef}})
	pkg/sentry/kernel/task_syscall.go:143 +0xb90 fp=0xc000f0f998 sp=0xc000f0f6e8 pc=0x103ae50
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallInvoke(0xc0008c5908, 0x1b4, {{0x3}, {0x1e}, {0x0}, {0x55f1b335dcb0}, {0x0}, {0x7c479a9ef}})
	pkg/sentry/kernel/task_syscall.go:323 +0x85 fp=0xc000f0fa40 sp=0xc000f0f998 pc=0x103cf65
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscallEnter(0xc0008c5908, 0x1b4, {{0x3}, {0x1e}, {0x0}, {0x55f1b335dcb0}, {0x0}, {0x7c479a9ef}})
	pkg/sentry/kernel/task_syscall.go:283 +0xc7 fp=0xc000f0fab0 sp=0xc000f0fa40 pc=0x103c8a7
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).doSyscall(0xc0008c5908)
	pkg/sentry/kernel/task_syscall.go:258 +0x53e fp=0xc000f0fbd0 sp=0xc000f0fab0 pc=0x103c3fe
gvisor.dev/gvisor/pkg/sentry/kernel.(*runApp).execute(0xc0008c5908?, 0xc0008c5908)
	pkg/sentry/kernel/task_run.go:269 +0x220c fp=0xc000f0fe78 sp=0xc000f0fbd0 pc=0x102740c
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).run(0xc0008c5908, 0x4c)
	pkg/sentry/kernel/task_run.go:97 +0x402 fp=0xc000f0ffb0 sp=0xc000f0fe78 pc=0x10247c2
gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).Start.gowrap1()
	pkg/sentry/kernel/task_start.go:416 +0x45 fp=0xc000f0ffe0 sp=0xc000f0ffb0 pc=0x10387a5
runtime.goexit({})
	src/runtime/asm_amd64.s:1700 +0x1 fp=0xc000f0ffe8 sp=0xc000f0ffe0 pc=0x486aa1
created by gvisor.dev/gvisor/pkg/sentry/kernel.(*Task).Start in goroutine 667
	pkg/sentry/kernel/task_start.go:416 +0x17e

Crashes (19):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2025/09/16 12:52 gvisor 0bb00ae3d273 e2beed91 .config console log report syz / log C ci-gvisor-ptrace-1-race-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 05:38 gvisor 9041e2310cf4 e2beed91 console log report syz / log C ci-gvisor-ptrace-2 panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 05:33 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-systrap-1-race panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 02:36 gvisor 9041e2310cf4 e2beed91 console log report syz / log C ci-gvisor-systrap-1 panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 22:20 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-ptrace-2-race panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 22:19 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-ptrace-1-race panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 22:12 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-systrap-1-race-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 22:03 gvisor 9041e2310cf4 e2beed91 console log report syz / log C ci-gvisor-ptrace-1 panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:38 gvisor 9041e2310cf4 e2beed91 console log report syz / log C ci-gvisor-kvm panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:35 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-kvm-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:32 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-systrap-1-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:26 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-ptrace-2-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:13 gvisor 57697a8f6350 e2beed91 .config console log report syz / log C ci-gvisor-ptrace-1-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 05:16 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-arm64-ptrace-1-race panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 04:02 gvisor 9041e2310cf4 e2beed91 console log report syz / log C ci-gvisor-arm64-systrap-1 panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 03:16 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-arm64-systrap-1-race-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:33 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log C ci-gvisor-arm64-ptrace-1-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/16 02:28 gvisor 9041e2310cf4 e2beed91 .config console log report syz / log ci-gvisor-arm64-systrap-1-race panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
2025/09/15 21:04 gvisor 57697a8f6350 e2beed91 .config console log report info ci-gvisor-ptrace-1-cover panic: Decrementing non-positive ref count ADDR, owned by tun.tunEndpoint
* Struck through repros no longer work on HEAD.