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

Unguarded division by zero panics the kernel in bw_frc_to_fixed / bw_floor2 / bw_ceil2

Summary

Fixed-point divide/floor/ceil helpers trust callers never to pass zero divisor. Only guard is ASSERT() which in this tree is WARN_ON (os_types.h:76->asm/bug.h:43-49) non-blocking kprintf so execution falls through into div64_u64_rem/div64_s64 whose DragonFly implementations (linux/math64.h:57-61,75-80) emit literal C %// by zero. On x86_64 raises #DE (trap 0) kernel context panics. bw_frc_to_fixed line 69 ASSERT(denominator!=0) WARN_ON then line 74 div64_u64_rem(arg1_value,arg2_value,...) computes arg1%0 arg1/0 both fault when arg2_value==0. bw_floor2 (119) bw_ceil2 (132) compute div64_s64(arg.value abs_i64(significance.value)) with NO guard whatsoever significance.value==0->div64_s64(arg.value 0)->panic. Reachable via amdgpu KMOD; bw_* helpers invoked heavily by dce_calcs.c/dcn_calcs.c with denominators from display-mode params (pixel_rate hsr/vsr bytes_per_request lb_line_pitch...). Degenerate display mode or crafted EDID from hostile/malfunctioning external monitor at hotplug (unauthenticated monitor/dock/USB-C attack) or local privileged user DRM mode-set ioctls could route zero divisor. Impact DoS kernel panic no priv-esc no info-leak. End-to-end attacker reachability not proven from this file depends on caller validation in dce_calcs.c/dcn_calcs.c hence likely not certain.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

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

DF-2155 - Verification Verdict

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

Verdict

Source-confirmed: bw_fixed div helpers (:69,119,132) use ASSERT(denominator!=0) which is WARN_ON non-blocking; div64 with 0 divisor β†’ UB/crash; GPU-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/drm/amd/display/dc/calcs/bw_fixed.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)

bw_fixed div ASSERT non-blocking; GPU-gated

Verified recommended fix

bw_fixed div ASSERT non-blocking; GPU-gated

Verdict

bw_fixed div ASSERT non-blocking; GPU-gated