β¬’ DragonFlyBSD Kernel Audit
← triage Β· dashboard
DF-1570

xa_close returns holding xdisk_lk and releases the wrong lock on race paths

Summary

xdisk.c:767 xa_close acquires xdisk_lk. 769-770 sc==NULL returns ENXIO WITHOUT releasing xdisk_lk -> permanent lock leak. 771-773 sc->terminating does lockmgr(&sc->lk, LK_RELEASE) releasing WRONG lock (never acquired sc->lk) AND returns without releasing xdisk_lk. Contrast xa_open (704-714) correctly releases xdisk_lk on all error paths. Once leaked every xa_open/xa_close/xdisk_attach/xaio_rcvdmsg blocks forever in lockmgr. Trigger: race where si_drv1 NULL or terminating at xa_close entry; currently unreachable but latent footgun. Fix: release xdisk_lk on both error paths.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1570 Β· 4 files
FileTypeDescriptionSize
fix.diff suggested-fix git-apply-able fix for the cited bug 506 B view raw
VERDICT.md verdict source-confirmation analysis 706 B ↓ raw
build.sh build-script N/A (source-only) 61 B view raw
run.sh run-script N/A (source-only) 87 B view raw
VERDICT.md verdict source-confirmation analysis
↓ download raw

DF-1570 VERDICT

Verdict: REPRODUCED (source-confirmed)

Impact: Low (driver-level NULL deref / OOB / leak / DoS β€” hardware-gated)

Mechanism: xdisk.c:767 xa_close acquires xdisk_lk. 769-770 sc==NULL returns ENXIO WITHOUT releasing xdisk_lk -> permanent lock leak. 771-773 sc->terminating does lockmgr(&sc->lk, LK_RELEASE) releasing WRONG lock

Citation: sys/dev/disk/xdisk/xdisk.c:767-793

Fix: Applied fix.diff β€” compiles in batch kernel build (rc=0, -Werror).

Verification method: Source-only line-by-line trace of cited path:line. Low-severity driver bug; PoC trigger requires specific hardware or root context. Confirmed the cited vulnerable pattern exists in source.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

fix.diff compiled in batch kernel build rc=0 -Werror

fix.diff compiled in batch kernel build rc=0 -Werror
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none (Low severity)

Evidence (decisive lines)

Source-confirmed: xa_close returns holding xdisk_lk and releases wrong lock sc->lk (xdisk.c:767-773)

Verified recommended fix

Source-confirmed: xa_close returns holding xdisk_lk and releases wrong lock sc->lk (xdisk.c:767-773)

Verdict

Source-confirmed: xa_close returns holding xdisk_lk and releases wrong lock sc->lk (xdisk.c:767-773)