DF-4846 / verdict.json
{ "finding_id": "DF-4846", "status": "reproduced", "reproduced": 1, "impact": "none", "confidence": "certain", "verdict": "Reproduced at feeder level on the audit guest against the real, unmodified sys/dev/sound/pcm/feeder_format.c: the build-time generated SND_FXDIV/SND_FXROUND table (sys/tools/sound/snd_fxdiv_gen.awk) is inexact WITHIN its claimed [1,65536] domain for every non-power-of-2 divisor (misrounds up from x=4694/5473/8195 for align 15/14/12; 15-40% of all counts), and feed_format_feed() sizes its pass with those macros: :220 FXROUND(count,oalign) can exceed the callers count so the source writes past the destination window and the return over-reports into sndbuf_acquire (ring overflow, buffer.c:615-636 KASSERT-only); :233 FXROUND(count,ialign) misrounds make j>count so src=dst+count-j lands BEFORE the window; :240 FXDIV of a user-paced partial source return miscounts a frame (over-conversion). Harness on pristine code with the real generated header: 8315/28200 checks fail with canary-guard hits; with the fixed generator (fix.diff: domain-exact reciprocals + 64-bit multiply) 0 failures. In-kernel reachability fully traced (feeder_chain.c:139-173 default insert on any encoding mismatch; buffer.c:705-709 arbitrary free counts; multichannel formats are unprivileged DSP ioctls); in-kernel churn (ES1370, 6ch+7ch vchans, bad-residue pacing) shows no differential anomaly vs aligned control on this no-INVARIANTS production kernel, as expected for a <=14-byte write past a kmalloc plus a silent ring overflow - same outcome and reasoning as DF-4710. Impact ceiling: 4-14-byte kernel heap OOB write past tmpbuf at exact-page allocation geometry + persistent sndbuf ring invariant breakage (rl inflated past bufsize; sndbuf_getfree=bufsize-rl wraps unsigned), unprivileged, default config.", "exploit_chain": "", "evidence": "fmt.log (baseline: checks=28200 failures=8315, REAR guard (write past window) + return > count + T3 over-conversion lines with exact counts/returns); fmt_fixed.log (fixed table: failures=0 ALL PASS); fxfmt.c/fxshim.h/fxsrc.c (harness compiling the pristine feeder_format.c with the real pcm.h/intpcm.h/g711.h/matrix.h headers and the real awk-generated snd_fxdiv_gen.h); VERDICT.md (full path:line chain)", "kernel_refs": [ "sys/dev/sound/pcm/feeder_format.c:220", "sys/dev/sound/pcm/feeder_format.c:233", "sys/dev/sound/pcm/feeder_format.c:237", "sys/dev/sound/pcm/feeder_format.c:240", "sys/dev/sound/pcm/feeder_format.c:246", "sys/dev/sound/pcm/feeder_chain.c:139-173", "sys/dev/sound/pcm/buffer.c:705", "sys/dev/sound/pcm/buffer.c:708-712", "sys/dev/sound/pcm/buffer.c:615-636", "sys/dev/sound/pcm/buffer.c:226", "sys/tools/sound/snd_fxdiv_gen.awk:56-71" ], "poc_changes": "PoC authored fresh in pass 2 (FXROUND follow-up lead from DF-4710): userland harness compiling the pristine feeder_format.c verbatim (#ifdef _KERNEL-gated file) with real kernel headers copied in and the real generated snd_fxdiv_gen.h. Three harness iterations: (1) arena bounds initially refused guard-region writes, masking violations - fixed to allow writes anywhere inside the guarded allocation so the canaries detect them; (2) source stub did not dry up (ready never decremented) - fixed; (3) volume feeder needed desc->type=FEEDER_VOLUME and matrix ids had to be the real matrix.h values.", "attempts": 6, "guest_uname": "DragonFly dfbsd 6.5-DEVELOPMENT DragonFly 6.5-DEVELOPMENT #0: Thu Jul 2 06:02:54 UTC 2026 root@dfbsd:/usr/obj/usr/src/sys/X86_64_GENERIC x86_64", "runtime_sec": 900, "guest_dirty": 0, "build_cmd": "cd /root/fx && sh build.sh (awk -f /usr/src/sys/tools/sound/snd_fxdiv_gen.awk > snd_fxdiv_gen.h; cc -O1 -g -o fxfmt fxfmt.c fxsrc.c)", "run_cmd": "./fxfmt # baseline FAIL; cp snd_fxdiv_gen_fixed.h snd_fxdiv_gen.h; rebuild -> ALL PASS", "code_hash": "", "notes": "Same idiom family as DF-4710 (feeder_eq, Medium due to root-gated eq=1) but feeder_format is DEFAULT-CONFIG reachable by unprivileged SNDCTL_DSP_SETFMT/CHANNELS, and the misround is NOT confined to the 65536 boundary - it starts at ordinary 8K buffer counts. snd_fxdiv table defect is shared root cause with DF-4847/4848/4849; the single generator fix (fix.diff) clears all four harnesses.", "recommended_fix": "Fix snd_fxdiv_gen.awk to emit domain-exact reciprocals ((d*mul-2^z)*65536 < 2^z) with a 64-bit multiply in SND_FXDIV (fix.diff); optionally also clamp each feeders count to <= the callers window.", "fix_status": "fixed", "fix_baseline_reproduced": 1, "fix_patched_reproduced": 0, "fix_verdict": "A/B validated at the level the defect was reproduced: identical harness, only the generated header swapped (baseline table vs fixed-generator table) - 8315 failures vs 0 (fmt.log vs fmt_fixed.log). Fixed table exhaustively verified exact for all 44 divisors over [1,65536]. Kernel rebuild A/B not performed: the in-kernel baseline observation on this rig was null (no INVARIANTS, <=14-byte write past kmalloc has no detector), so a rebuilt kernel had no observable to compare - same standard as DF-4710.", "fix_evidence": "fmt_fixed.log (failures=0 ALL PASS); fix.diff; snd_fxdiv_gen_fixed.awk" } |