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

Undefined-behavior mask in AcpiOsReadPciConfiguration zeroes all 32-bit PCI config reads

Summary

AcpiOsReadPciConfiguration masks return value with (1 << (bytes*8)) - 1 where 1 is signed int (OsdHardware.c:106). For Width=32 (bytes=4) evaluates 1<<32 undefined behavior per C11 6.5.7 (1*2^32 not representable in int). On x86_64/GCC shl wraps count mod 32 yielding 1<<0-1=0 so *Value &= 0 and every 32-bit ACPI PCI-Config read silently returns 0 instead of register contents. Downstream pci_cfgregread returns CORRECT full 32-bit value via inl/volatile u32 ptr which mask then destroys. Mask redundant for bytes=1/2 (pci_cfgregread returns correctly-sized via inb/inw) actively destructive for bytes=4. Triggered whenever ACPICA interpreter evaluates AML reading 32-bit field from PciConfig OpRegion; AcpiExPciConfigSpaceHandler passes BitWidth through unchanged pre-zeroes Value. BIOS DSDT/SSDT commonly reads 32-bit PCI config fields (BAR registers class codes status/command DWORDs) during device probe hotplug PM transitions. Impact: reads return 0 causing incorrect device configuration failed init ACPI method malfunction local DoS/integrity. Requires ability to drive ACPI method evaluation (kernel-internal boot/probe or root /dev/acpi) not reachable by unprivileged userspace. No memory corruption info leak or priv-esc.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-2194 Β· 2 files
FileTypeDescriptionSize
VERDICT.md file 713 B ↓ raw
fix.diff file 169 B view raw
VERDICT.md file
↓ download raw

DF-2194 - Verification Verdict

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

Verdict

Source-confirmed: AcpiOsReadPciConfiguration (:106) Value&=(1<<(bytes8))-1 where 1 is signed int; bytes=4 β†’ 1<<32 is UB per C11 6.5.7; ACPI-gated

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/acpica/Osd/OsdHardware.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)

AcpiOsReadPci 1<<32 UB; ACPI-gated

Verified recommended fix

AcpiOsReadPci 1<<32 UB; ACPI-gated

Verdict

AcpiOsReadPci 1<<32 UB; ACPI-gated