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

Divide-by-zero in SCLK/MCLK spread-spectrum math from VBIOS-controlled zero rates

Summary

tonga_calculate_sclk_params at :591: clkS=reference_clock*5/(reference_divider*ss_info.speed_spectrum_rate). tonga_calculate_mclk_params at :883/:889: clks=reference_clock*5/ss_info.speed_spectrum_rate; clkv=.../freq_nom. ss_info.speed_spectrum_rate from VBIOS usSpreadRateInKhz (no zero check in atomctrl). Crafted VBIOS with usSpreadRateInKhz=0 -> divide-by-zero #DE panic at powerplay init. Sibling of DF-1204 (ni_dpm ss.rate). Fix: check rate!=0 before division.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-1274 Β· 12 files
FileTypeDescriptionSize
trigger.c trigger-source documentation stub; bug path is VBIOS-parse/GPU-init, not a syscall 1.0 KB view raw
fix.diff suggested-fix git-apply-able fix 1.1 KB view raw
build.sh repro-script build the stub 470 B view raw
run.sh repro-script run the stub 244 B view raw
build.log build-log trigger build output 71 B view raw
run.log run-log trigger run output (no effect; latent) 65 B view raw
VERDICT.md verdict full source-level trace + fix rationale 2.0 KB ↓ raw
env.txt environment guest uname, modules, PCI (no GPU) 1.7 KB view raw
fix_build.log build-log compile-validation: kernel+module build with fix applied, rc=0, no errors 21.5 KB view raw
README.md readme human reproduce doc 501 B ↓ raw
../fix_build_combined.log build-log Combined 41-finding kernel build (rc=0, -Werror clean) 5.6 MB ↓ download
../fix_build_summary.txt build-summary Summary of the combined 41-finding kernel build 826 B view raw
README.md readme human reproduce doc
↓ download raw

DF-1274 PoC β€” tonga spread-spectrum divide-by-zero (LATENT)

Status: source-confirmed real; NOT reproducible on audit guest (no AMD GPU). Impact: divide-by-zero (#DE) panic at powerplay init via crafted VBIOS usSpreadRateInKhz=0. Driver: sys/dev/drm/amd/powerplay/smumgr/tonga_smumgr.c (amdgpu powerplay, not in GENERIC, no HW). Sibling of DF-1204 (ni_dpm ss.rate).

Reproduce

./build.sh && ./run.sh   # stub; bug path is GPU powerplay init

See VERDICT.md + fix.diff.

VERDICT.md verdict full source-level trace + fix rationale
↓ download raw

DF-1274 β€” tonga SCLK/MCLK spread-spectrum divide-by-zero (LATENT)

Verdict

NOT REPRODUCED on the audit guest (LATENT / HW-gated). The bug is confirmed real by source-level trace; it cannot fire here because there is no AMD GPU, so the dev/drm/amd/powerplay/smumgr/tonga_smumgr.c path is dead at runtime.

Mechanism (confirmed in source)

  • tonga_calculate_sclk_params (tonga_smumgr.c:591): clkS = reference_clock * 5 / (reference_divider * ss_info.speed_spectrum_rate);
  • tonga_calculate_mclk_params (tonga_smumgr.c:883): clks = reference_clock * 5 / ss_info.speed_spectrum_rate;
  • ss_info.speed_spectrum_rate is loaded directly from the VBIOS field usSpreadRateInKhz (ppatomctrl.c:1248, ssEntry->speed_spectrum_rate = le16_to_cpu(ssInfo->usSpreadRateInKhz);) with no zero check in atomctrl_get_{engine,memory}_clock_spread_spectrum.
  • reference_divider = 1 + dividers.uc_pll_ref_div (tonga_smumgr.c:~559) so it is always β‰₯ 1; the sole zero divisor is ss_info.speed_spectrum_rate.
  • A crafted VBIOS with usSpreadRateInKhz == 0 β‡’ integer divide-by-zero (#DE) β‡’ fatal trap / kernel panic at powerplay init.
  • Sibling of DF-1204 (ni_dpm ss.rate), same class, fixed the same way.

Why it does not reproduce here

No AMD GPU on the guest; tonga_smumgr attaches only to Tonga/Fiji/Polaris AMD GPUs via powerplay. Reaching the bug needs that hardware + a crafted VBIOS. Valid hard blocker.

Exploit chain

N/A β€” divide-by-zero DoS (panic), HW-gated (latent). No write primitive.

PoC changes

trigger.c is a documentation stub.

Fix (fix.diff)

Skip spread-spectrum programming when the VBIOS rate is zero, by tightening both if (0 == atomctrl_get_*_clock_spread_spectrum(...)) conditions to also require ss_info.speed_spectrum_rate != 0. Matches the finding proposal ("check rate!=0 before division") and the DF-1204 fix pattern. Applies cleanly (patch -p1 rc=0).

Fix validation

not_testable β€” code path unreachable on audit guest; diff applies cleanly, syntactically reviewed.

Fix verification

not_testable

compile validated

kernel/module build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none

Evidence (decisive lines)

β€”

Verdict

Source-confirmed. tonga ss.speed_spectrum_rate=0 -> div-by-zero #DE. amdgpu not in GENERIC.