Bug 291249 - kgssapi panic at module unload (panic: __rw_wlock_hard: recursing but non-recursive rw 0xffffffff81cd6e60 @ /.../sys/rpc/clnt_nl.c:467)
Summary: kgssapi panic at module unload (panic: __rw_wlock_hard: recursing but non-rec...
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Ed Maste
URL: https://reviews.freebsd.org/D53949
Keywords: crash
Depends on:
Blocks:
 
Reported: 2025-11-27 16:16 UTC by Ed Maste
Modified: 2025-11-28 01:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Maste freebsd_committer freebsd_triage 2025-11-27 16:16:50 UTC
On a WIP branch from main as of today, 4e22cd3bf0b4112e541bc585a6be57662cb0b52b
To reproduce, `kldload kgssapi.ko && kldunload kgssapi.ko`

panic: __rw_wlock_hard: recursing but non-recursive rw 0xffffffff81cd6e60 @ /home/emaste/src/freebsd-git/wipbsd/sys/rpc/clnt_nl.c:467

cpuid = 0
time = 1764260052
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe004ad98a80
vpanic() at vpanic+0x136/frame 0xfffffe004ad98bb0
panic() at panic+0x43/frame 0xfffffe004ad98c10
__rw_wlock_hard() at __rw_wlock_hard+0x7c7/frame 0xfffffe004ad98cb0
_rw_wlock_cookie() at _rw_wlock_cookie+0xac/frame 0xfffffe004ad98cf0
clnt_nl_destroy() at clnt_nl_destroy+0x199/frame 0xfffffe004ad98d10
kgssapi_modevent() at kgssapi_modevent+0x2c8/frame 0xfffffe004ad98d50
module_unload() at module_unload+0x38/frame 0xfffffe004ad98d70
linker_file_unload() at linker_file_unload+0x22b/frame 0xfffffe004ad98dc0
kern_kldunload() at kern_kldunload+0x190/frame 0xfffffe004ad98e00
amd64_syscall() at amd64_syscall+0x174/frame 0xfffffe004ad98f30
fast_syscall_common() at fast_syscall_common+0xf8/frame 0xfffffe004ad98f30
Comment 1 Ed Maste freebsd_committer freebsd_triage 2025-11-27 16:43:57 UTC
Introduced in ad704a34bc2c, which added kgss_unload() and mtx_destroy(&kgss_gssd_lock) to the MOD_UNLOAD case above the comment which states unload is not supported and falls through to error = EOPNOTSUPP.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2025-11-27 21:25:16 UTC
^Triage: Cc: committer of ad704a34bc2c .
Comment 3 commit-hook freebsd_committer freebsd_triage 2025-11-28 01:30:22 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6901376f59b870ddbb0d922e3455a388333cd460

commit 6901376f59b870ddbb0d922e3455a388333cd460
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2025-11-27 16:44:08 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2025-11-28 01:29:55 +0000

    kgssapi: Remove broken MOD_UNLOAD code

    The module panicked at unload with "recursing but non-recursive rw".
    There is a comment that "Unloading of the kgssapi module is not
    currently supported" and the MOD_UNLOAD case falls through to returning
    EOPNOTSUPP anyway.  Just #if 0 the code in the unload path, leaving it
    as a hint in case someone implements unload support later on.

    PR:             291249
    Reviewed by:    rmacklem
    Fixes: ad704a34bc2c ("Use syscall_helper_register(9) rather than syscall_register().")
    Sponsored by:   The FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D53949

 sys/kgssapi/gss_impl.c | 4 ++++
 1 file changed, 4 insertions(+)