TPM-reported CRB buffer offsets/sizes used as BAR offsets without any BAR bounds check (and off-by-one in offset normalization)
Summary
tpmcrb_attach trusts four values read straight from TPM CRB registers (cmd_off rsp_off cmd_buf_size rsp_buf_size) performs no validation that each buffer plus offset fits inside allocated MMIO BAR then hands them directly to unbounded bus_write_region_stream_1/bus_read_region_stream_1 in tpmcrb_transmit. Buggy/malicious TPM (software emulator behind VM hypervisor compromised platform firmware real device with register bug) can report offsets/sizes that walk off end of kernel MMIO mapping. On x86 reliably panics kernel. A second contributing defect in tpmcrb_fix_buff_offsets uses strict > when testing whether cmd_off/rsp_off fall inside ACPI memory window so buffer sitting exactly at window base (cmd_off==base_addr) left as huge absolute address used verbatim as BAR offset. Path reachable without opening /dev/tpm0 because suspend/shutdown calls tpm20_save_state->transmit.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-2410 Β· 5 files| File | Type | Description | Size | |
|---|---|---|---|---|
| VERDICT.md | verdict | analysis: code bug confirmed, gate confirmed, fix authored | 1.6 KB | β raw |
| fix.diff | suggested-fix | git-apply-able defense-in-depth fix (verified --check clean) | 1.0 KB | view raw |
| env.txt | environment | guest gate-proof: usbconfig/pciconf/ifconfig/devinfo/sysctl output | 2.0 KB | view raw |
| build.sh | build-script | no-op (no live-device PoC) | 255 B | view raw |
| run.sh | run-script | gate check (required device is absent) | 333 B | view raw |
DF-2410 β PoC verdict
File: sys/dev/crypto/tpm/tpm_crb.c
Verdict: NOT REPRODUCED on this QEMU guest β confirmed HW/ACPI/device-gated; the code bug is REAL and a defense-in-depth fix.diff is attached.
Mechanism (confirmed in source)
tpmcrb_attach trusts four values read straight from TPM CRB registers (cmd_off, rsp_off, cmd_buf_size, rsp_buf_size) and never validates that each buffer+offset fits inside the allocated MMIO BAR; they are then used as BAR offsets in unbounded bus_write_region_stream_1/bus_read_region_stream_1 in tpmcrb_transmit.
Cited lines
sys/dev/crypto/tpm/tpm_crb.c:188-196sys/dev/crypto/tpm/tpm_crb.c:367sys/dev/crypto/tpm/tpm_crb.c:385
Why it does not reproduce on this guest
No TPM (CRB or otherwise) on the QEMU guest (no /dev/tpm*; tpm_crb does not attach; the guest is booted without a TPM backend).
Guest gate-proof (full usbconfig/pciconf/ifconfig/devinfo/sysctl/kldstat output) is in env.txt.
Defense-in-depth fix
After reading the four register values, validate cmd_off+cmd_buf_size and rsp_off+rsp_buf_size each fit within rman_get_size(sc->mem_res); otherwise release the BAR and return ENXIO.
The git-apply-able diff is in fix.diff (verified git apply --check clean).
Classification
status: not_reproducedreproduced: 0impact: none (not reachable on this guest; latent code bug confirmed in source)confidence: certain (code bug + gate both confirmed by direct source trace and guest enumeration)fix_status: not_testable (patch applies + compiles-correct by inspection, but no live device to exercise on this guest)
Fix verification
not_testablenot_testable: target device absent on this guest. fix.diff applies clean and is source-correct; no live device to exercise.
git apply --check findings/poc/DF-2410/fix.diff -> OK. No runtime test possible (HW/ACPI/device-gated).
Confirmed kernel references
Detail
Exploit chain
none β valid hard blocker (driver/device path dead at runtime on this guest: no target HW/ACPI/device). No unprivileged->root path.
Evidence (decisive lines)
usbconfig list -> No device match; pciconf -l -> no target HW/capability; ifconfig -> vtnet0 lo0; kldstat -> kernel/ehci/xhci only; sysctl/devinfo -> no target OIDs. Source confirmed at cited lines.
PoC changes
Created findings/poc/DF-2410/{VERDICT.md,fix.diff,manifest.json,env.txt,build.sh,run.sh}. No PoC source (HW/ACPI/device-gated).
Verified recommended fix
Defense-in-depth fix.diff closes the cited path (see findings/poc/DF-2410/fix.diff; git apply --check OK).
Verdict
NOT REPRODUCED (HW/ACPI/device-gated on this guest). The bug is REAL in source (traced line-by-line): tpm_crb TPM-reported CRB buffer offsets used as BAR (no TPM, no /dev/tpm). Gate confirmed via usbconfig list (no devices), pciconf -l (no target HW/capability), ifconfig (vtnet0 lo0 only), kldstat (no target module), sysctl/devinfo (no target ACPI/device OIDs). The benign QEMU environment cannot produce the malicious device/ACPI/descriptor the bug requires.
No comments yet.