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

amdparsemsg MSG_DISCONNECT writes through NULL active_srb after an unexpected reselection

Summary

On an unexpected reselection (untagged_srbs[t][l]==NULL, disc_count==0) amd_Reselect leaves active_srb NULL after queueing the ABORT; a hostile target that ignores ATN and clocks a MSG_DISCONNECT byte in MSG IN reaches the MSG_DISCONNECT arm which writes active_srb->SRBState - NULL-page write fault in interrupt context. The Q_TAG and msgreject arms guard active_srb!=NULL; this arm is the unguarded hole. Verified (child SIGSEGV on the exact store). NULL-guard fix.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-4044 Β· 12 files
FileTypeDescriptionSize
amd_walks.c β€” 10.2 KB view raw
build.sh β€” 65 B view raw
run.sh β€” 89 B view raw
build.log β€” 184 B view raw
run.log β€” 2.0 KB view raw
env.txt β€” 832 B view raw
fix.diff β€” 433 B view raw
fix_build.log β€” 1.2 KB view raw
README.md β€” 1015 B ↓ raw
VERDICT.md β€” 2.5 KB ↓ raw
manifest.json β€” 860 B view raw
verdict.json β€” 3.4 KB view raw

DF-4044 β€” amdparsemsg MSG_DISCONNECT writes through NULL active_srb after an unexpected reselection

File: sys/dev/disk/amd/amd.c Severity: Medium | Class: CWE-476 NULL Pointer Dereference Status: hardware-gated β€” source-certain; runtime reproduction impossible on the audit guest (no AMD53C974 HBA β€” see env.txt). Verdict: inconclusive, confidence certain.

Build & run (on the DragonFly guest)

./build.sh     # compiles the demonstrator (verbatim-copy of the driver walks)
./run.sh       # reproduces the exact branch selection / fault

Expected: the DF-4044 section of run.log shows the panic-branch selection / fault. Full guest details in env.txt.

Fix validation

fix.diff applied (with all DF-4036..DF-4044 patches together) to a clean guest /usr/src copy; make nativekernel KERNCONF=X86_64_GENERIC completed with 0 errors under -Werror (see fix_build.log β€” amd.o recompiled into the GENERIC kernel). Sources restored to pristine afterwards (md5-verified).

VERDICT.md
↓ download raw

DF-4044 VERDICT β€” amdparsemsg MSG_DISCONNECT writes through NULL active_srb after an unexpected reselection

Bottom line

Source-certain NULL write: on an unexpected reselection (untagged_srbs[t][l]==NULL and disc_count==0, amd.c:1834-1836) amd_Reselect leaves amd->active_srb NULL after queueing the ABORT (:1843 skipped). A hostile target that ignores ATN and clocks a MSG_DISCONNECT byte in MSG IN reaches amdparsemsg case MSG_DISCONNECT (amd.c:1217) which writes amd->active_srb->SRBState (:1218) β€” a NULL-page write fault in amd_intr context => kernel panic. The Q_TAG case guards active_srb!=NULL (:1229) and amdhandlemsgreject guards srb!=NULL (:1475); the DISCONNECT arm is the unguarded hole. Verified with a child process taking SIGSEGV on the exact store (run.log DF-4044). Hostile-target gated -> runtime inconclusive on this guest, source certain.

Exploit chain

hostile target: reselect an idle target/lun (active_srb=NULL, driver queues ABORT) -> send MSG_DISCONNECT byte -> amd_MsgInPhase0:1188 -> amdparsemsg:1218 NULL write => panic

Why not reproduced on the guest

The audit guest has no AMD53c974-compatible SCSI HBA (env.txt); amd(4) is compiled into the GENERIC kernel (X86_64_GENERIC:88 device amd) but never attaches, so the hostile-target message flows cannot be exercised at runtime. The exact walks were compiled from the driver source (verbatim amdsentmsg copy / exact branch ladder / exact store) and driven with the real driver states (run.log); the fix is compile-validated (fix_build.log).

Negative results recorded alongside (pass-2 depth)

Kills proven in run.log: msgin_buf[6] per-byte walk max index 4 (bounded); SRB_array[msgin_buf[1]] 0..255 fits SRB_array[256] exactly; msgout shift bcopy fits msgout_buf[6]; amdtimeout/callout family is #if 0 dead code (no timeout-vs-intr race); EEPROM word walks fit eepromBuf[128] exactly; XPT_RESET_BUS ACBFlag race can only strand CCBs (hang, logged, not filed).

Fix

NULL-guard active_srb in the MSG_DISCONNECT arm (skip the state store and disc_count bump; still complete the message). Applied and compile-validated on the guest (fix_build.log); sys/ tree never modified by the audit.

Fix status (batch validation)

Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.

Fix verification

fixed
baseline no→ patch + rebuild →patched clean

fixed (compile-validated): all nine patches applied together to the clean guest /usr/src copy (polaris10_smumgr.c md5 6f39bb32..->19a2b278.., amd.c f577a330..->54ce1518..), make -j4 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with 0 compile errors under -Werror; amd.o recompiled into the GENERIC kernel. Runtime re-test impossible on this guest (device absent). Sources restored to pristine and md5-verified after validation.

findings/poc/DF-4044/fix.diff; findings/poc/DF-4044/fix_build.log (build banner + compile lines + 0 errors)
↓ fix.diffDragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64 (nativekernel X86_64_GENERIC rebuilt with all DF-4036..DF-4044 patches; 0 errors under -Werror; see fix_build.log)

Confirmed kernel references

Detail

Exploit chain

hostile target: reselect an idle target/lun (active_srb=NULL, driver queues ABORT) -> send MSG_DISCONNECT byte -> amd_MsgInPhase0:1188 -> amdparsemsg:1218 NULL write => panic

Evidence (decisive lines)

run.log section DF-4044 (child signal 11 on active_srb->SRBState with NULL); VERDICT.md; fix_build.log; env.txt

PoC changes

Pass-2 reviewer authored demonstrator with a verbatim copy of the driver's amdsentmsg walk / handlemsgreject branch ladder / parsemsg DISCONNECT arm so branch selection is the kernel's; fix.diff generated against the pristine file and compile-validated via full nativekernel rebuild on the guest (shared build with DF-4036..DF-4044, fix_build.log).

Verified recommended fix

NULL-guard active_srb in the MSG_DISCONNECT arm (skip the state store and disc_count bump; still complete the message)

Verdict

Source-certain NULL write: on an unexpected reselection (untagged_srbs[t][l]==NULL and disc_count==0, amd.c:1834-1836) amd_Reselect leaves amd->active_srb NULL after queueing the ABORT (:1843 skipped). A hostile target that ignores ATN and clocks a MSG_DISCONNECT byte in MSG IN reaches amdparsemsg case MSG_DISCONNECT (amd.c:1217) which writes amd->active_srb->SRBState (:1218) β€” a NULL-page write fault in amd_intr context => kernel panic. The Q_TAG case guards active_srb!=NULL (:1229) and amdhandlemsgreject guards srb!=NULL (:1475); the DISCONNECT arm is the unguarded hole. Verified with a child process taking SIGSEGV on the exact store (run.log DF-4044). Hostile-target gated -> runtime inconclusive on this guest, source certain.