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

Signed-integer overflow UB in SM() shift of EEPROM antdiv_ctl1

Summary

SM(_v _f) macro (ah_internal.h:579) expands to ((_v)<<_f##_S)&(_f). ant_div_control1 uint8_t promoted to signed int. Shifts (ant_div_control1>>1)<<29 at ar9285_diversity.c:98 and (ant_div_control1>>2)<<30 at :99 invoke UB whenever EEPROM antdiv_ctl1 low nibble >=8 (values 8..15): 4<<29=0x80000000 exceeds INT_MAX signed overflow UB; 2<<30=0x80000000 same. Result immediately AND-masked with field mask so actual register bits written correct on every compiler/platform in practice but source not standards-conformant UBSan flags it. antdiv_ctl1 from EEPROM 4-bit field (ah_eeprom_v4k.h:128 135); settable by malicious AR9285 adapter or root EEPROM tools. Only sinks OS_REG_WRITE to PHY registers no kernel memory touched as function of these values. Fix: cast SM operand to uint32_t before shift (ah_internal.h:579 one-line macro fix removes entire class across HAL).

Discussion (0)

No comments yet.

PoC verification

Evidence pack

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

DF-2179 - Verification Verdict

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

Verdict

Source-confirmed: ar9285_diversity (:98-99) SM macro shifts uint8_t promoted to signed int; <<29 into sign bit is UB per C11 6.5.7; masked by &_f in practice; WiFi-HW-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/netif/ath/ath_hal/ar9002/ar9285_diversity.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)

ar9285 SM UB shift; WiFi-gated

Verified recommended fix

ar9285 SM UB shift; WiFi-gated

Verdict

ar9285 SM UB shift; WiFi-gated