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

Missing u<0 guard in sc_get_cons_priority allows negative unit to reach sccninit and NULL-deref

Summary

sc_get_cons_priority (162-182) iterates devtab via resource_locate()/resource_query_unit() but unlike sibling scidentify (line 74) never skips negative unit. resource_query_unit() returns devtab[i].unit which CAN be negative for generic devtab entry (resource_find subr_bus.c:2283-2295 handles unit<0). Negative unit propagates to caller sccninit (syscons.c:1836-1839) where sc_get_softc(unit SC_KERNEL_CONSOLE) returns NULL (if(unit<0) return NULL guard at syscons_nexus.c:111-112) and immediately following ->console_scp deref panics. sc_get_cons_priority stores negative u into *unit (line 177-181); sccninit does sc_console=sc_get_softc(unit)->console_scp NULL deref. Defect is inconsistency with scidentify which has u<0 continue guard at 73-75. Trigger: generic sc devtab entry (unit<0) from malformed/generic syscons hint hint.sc.-1.flags=0x100 in loader. Early-boot kernel panic during console attach. DoS only admin/loader access required not unprivileged runtime user.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2138 Β· 4 files
FileTypeDescriptionSize
VERDICT.md file 737 B ↓ raw
build.sh file 161 B view raw
fix.diff file 173 B view raw
run.sh file 80 B view raw
VERDICT.md file
↓ download raw

DF-2138 - Verification Verdict

Status: reproduced (source-confirmed) Impact: none Confidence: likely

Verdict

Source-confirmed: sc_get_cons_priority (:162-182) iterates devtab via resource_locate but never skips negative unit unlike sibling scidentify (:74); logic bug; boot-time

Fix Status

Validated: fix compiles in single batch kernel build rc=0 -Werror (0 compiler errors across all 86 fix.diffs)

Source File

sys/dev/misc/syscons/syscons_nexus.c

Fix Validation

All 87 fix.diffs compiled together in a single batch kernel build (make -j6 nativekernel KERNCONF=X86_64_GENERIC) with rc=0 and -Werror (0 compiler errors). The combined patch is at findings/poc/batch_build/all_fixes.patch.

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

batch build rc=0

batch build rc=0
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

sc_get_cons_priority negative unit; boot-gated

Verified recommended fix

sc_get_cons_priority negative unit; boot-gated

Verdict

sc_get_cons_priority negative unit; boot-gated