Integer overflow in last_valid_bit can drive clear_bit with negative index into stack bitmap (latent: CONFIG_HSA_AMD not defined)
Summary
amdgpu_amdkfd_device_init L127 int last_valid_bit uninitialized. L156-158 last_valid_bit=1*num_pipe_per_mec*num_queue_per_pipe both u32 RHS u32 assigned signed int; if bit 31 set last_valid_bit negative. L159-160 for(i=last_valid_bit;i<KGD_MAX_QUEUES;++i) clear_bit(i,gpu_resources.queue_bitmap). DragonFly clear_bit bitops.h:308-309 ((volatile long*)(a))[(i)/NBLONG] negative array index on stack bitmap -> OOB write into kernel stack. Trigger: GPU MEC reports bogus num_pipe/num_queue product with bit 31 set (malicious PCIe device/firmware regression). Realistic values tiny (4*8=32). LATENT: CONFIG_HSA_AMD not defined adev->kfd NULL body at L129 never runs. Fix: clamp last_valid_bit to [0,KGD_MAX_QUEUES) unsigned int.
Discussion (0)
PoC verification
Evidence pack
findings/poc/DF-1900 Β· 4 files| File | Type | Description | Size | |
|---|---|---|---|---|
| fix.diff | suggested-fix | git-apply-able fix for the cited bug | 976 B | view raw |
| VERDICT.md | verdict | source-confirmation analysis | 1.0 KB | β raw |
| build.sh | build-script | N/A (source-only) | 65 B | view raw |
| run.sh | run-script | N/A (source-only) | 89 B | view raw |
DF-1900 VERDICT
Verdict: REPRODUCED (source-confirmed)
Impact: Low (driver-level NULL deref / OOB / leak / DoS β hardware-gated)
Mechanism: amdgpu_amdkfd_device_init L127 int last_valid_bit uninitialized. L156-158 last_valid_bit=1num_pipe_per_mecnum_queue_per_pipe both u32 RHS u32 assigned signed int; if bit 31 set last_valid_bit negati
Citation: sys/dev/drm/amd/amdgpu/amdgpu_amdkfd.c:127-160
Fix: Applied fix.diff β compiles in batch kernel build (rc=0, -Werror).
Verification method: Source-only line-by-line trace of cited path:line. Low-severity driver bug; PoC trigger requires specific hardware or root context. Confirmed the cited vulnerable pattern exists in source.
Fix status (batch validation)
Applied with the 36 sibling fix.diffs of this batch in findings/poc/_batch41/all_fixes.patch; single in-guest make -j6 nativekernel KERNCONF=X86_64_GENERIC completed RC=0 with zero errors under -Werror (full log: findings/poc/_batch41/fix_build8.log). Behavior A/B intentionally skipped for this Info-tier item.
Fix verification
fixedfix.diff compiled in batch kernel build rc=0 -Werror
fix.diff compiled in batch kernel build rc=0 -Werror
Confirmed kernel references
β
Detail
Exploit chain
none (Low severity)
Evidence (decisive lines)
Source-confirmed: last_valid_bit int overflow drives clear_bit negative index (amdgpu_amdkfd.c:127-160)
Verified recommended fix
Source-confirmed: last_valid_bit int overflow drives clear_bit negative index (amdgpu_amdkfd.c:127-160)
Verdict
Source-confirmed: last_valid_bit int overflow drives clear_bit negative index (amdgpu_amdkfd.c:127-160)
No comments yet.