Page MenuHomeFreeBSD

tty: fix panic with INVARIANTS
ClosedPublic

Authored by rew on Feb 22 2022, 4:42 AM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 7 2024, 12:29 PM
Unknown Object (File)
Mar 24 2024, 1:06 PM
Unknown Object (File)
Mar 8 2024, 12:04 AM
Unknown Object (File)
Jan 12 2024, 9:25 AM
Unknown Object (File)
Dec 22 2023, 11:11 PM
Unknown Object (File)
Dec 19 2023, 2:27 AM
Unknown Object (File)
Oct 13 2023, 8:40 AM
Unknown Object (File)
Sep 6 2023, 6:39 PM
Subscribers

Details

Summary

reported at https://lists.freebsd.org/archives/freebsd-current/2022-February/001564.html

watch'ing a tty triggers a refcount wraparound panic:

 % watch ttyu0

panic: refcount 0xfffff80003bb97d4 wraparound
cpuid = 1
time = 1645472248
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe00827d0c80
vpanic() at vpanic+0x17f/frame 0xfffffe00827d0cd0
panic() at panic+0x43/frame 0xfffffe00827d0d30
fdclose() at fdclose/frame 0xfffffe00827d0dc0
closefp_impl() at closefp_impl+0x77/frame 0xfffffe00827d0e00
amd64_syscall() at amd64_syscall+0x12e/frame 0xfffffe00827d0f30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe00827d0f30
--- syscall (6, FreeBSD ELF64, sys_close), rip = 0x8011e8f7a, rsp = 0x7fffffffe0b8, rbp = 0x7fffffffe4f0 ---
KDB: enter: panic
[ thread pid 709 tid 100091 ]
Stopped at      kdb_enter+0x37: movq    $0,0x1281ffe(%rip)
db>

Take a reference on the file after fget_cap_locked() to fix.

Reported by: Michael Jung <mikej_at_paymentallianceintl.com>
Fixes: f40dd6c8034b ("tty: switch ttyhook_register to use fget_cap_locked")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

rew requested review of this revision.Feb 22 2022, 4:42 AM
rew added a reviewer: mjg.
This revision is now accepted and ready to land.Feb 22 2022, 9:18 AM

Heh. I was looking at all other fd changes thinking fp is perhaps set, the func fails and fdrops and then some caller blindly uses it.

Thank you for looking into it.

This revision was automatically updated to reflect the committed changes.