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

Undefined behavior: shift by sysctl-controlled token_window_shift in backoff spin

Summary

_lwkt_trytokref_spin (lwkt_token.c:400/:413): rdtsc()>>(int)token_window_shift; token_window_shift writable via SYSCTL_INT CTLFLAG_RW (:157-158). rdtsc returns tsc_uclock_t 64-bit unsigned. If root sets negative or >=64, shift is UB (C11 6.5.7). Impact: unpredictable backoff-window (scheduling fairness) only, NOT memory corruption/info leak. Root-only. Fix: clamp [0,63] or mask &63.

Discussion (0)

No comments yet.

PoC verification

Evidence pack

findings/poc/DF-0066 Β· 1 files
FileTypeDescriptionSize
fix.diff suggested-fix Undefined behavior: shift by sysctl-controlled token_window_shift in backoff spi 379 B view raw

Fix verification

fixed
baseline reproduced→ patch + rebuild →patched clean

fix.diff applied + combined nativekernel build rc=0 (-Werror)

fix.diff applied + combined nativekernel build rc=0 (-Werror)
↓ fix.diffcombined build rc=0

Confirmed kernel references

β€”

Detail

Exploit chain

none (Info severity)

Evidence (decisive lines)

Source-confirmed at sys/kern/lwkt_token.c:398: UB shift by sysctl-controlled token_window_shift

Verified recommended fix

Source-confirmed at sys/kern/lwkt_token.c:398: UB shift by sysctl-controlled token_window_shift

Verdict

Source-confirmed at sys/kern/lwkt_token.c:398: UB shift by sysctl-controlled token_window_shift