DF-4939 / verdict.json
{ "finding_id": "DF-4939", "status": "reproduced", "reproduced": 1, "impact": "leak", "confidence": "certain", "verdict": "REPRODUCED: every SIOCSIFFLAGS down->up cycle on if_ic leaks 2 x (if_mtu+4) bytes of M_DEVBUF because the down branch (if_ic.c:179-187) never frees ic_obuf/ic_ifbuf and the up branch (if_ic.c:193-197) unconditionally re-kmallocs both. Demonstrated on the QEMU guest with a virtual-I2C-bridge harness KLD: 300/300 cycles leaked, M_DEVBUF grew 219->619->819 allocs (214K->814K->1.09M) for 200+100 cycles, exactly +2 allocs/+3008B per cycle. Deterministic, unbounded, privileged trigger (root loop can exhaust kernel heap). Fix (allocate-only-if-NULL in the up branch) validated by rebuilding if_ic.ko on the guest: same 200-cycle workload is byte-flat (219/214K -> 219/214K).", "exploit_chain": "", "evidence": "run.log: baseline devbuf 219/214K -> 619/814K after 200 cycles -> 819/1.09M after +100 (exactly 2 allocs per cycle); FIX section of run.log: patched module byte-flat 219/214K -> 219/214K across the same 200 cycles. Harness lpbbfake.c + Makefile.harness attach ic0 with no i2c hardware.", "kernel_refs": [ "sys/dev/netif/ic/if_ic.c:179-187", "sys/dev/netif/ic/if_ic.c:193-197", "sys/net/if.c:2134-2175" ], "poc_changes": "Pass-1-style PoC sketch did not exist for this finding (new pass-2 finding). Had to invent the reproduction environment: guest has no I2C controller, so a virtual lpbb bit-bang bridge KLD (lpbbfake.c) was written to instantiate lpbb->iicbb->iicbus->ic0. Also: ifconfig requires a destination address for the point-to-point ic0 (ifconfig ic0 A B netmask ... up).", "attempts": 2, "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": 420, "guest_dirty": 0, "build_cmd": "see build.sh (make lpbbfake.ko; fix build: cd /usr/src/sys/dev/netif/ic && make after applying fix.diff)", "run_cmd": "see run.sh (kldload stack; ifconfig ic0 up; 200x down/up; vmstat -m)", "code_hash": "0879aeea3cdef90f59261e285450c38a94c646738086108e20bac23bfedb3084", "notes": "Privileged trigger (SIOCSIFFLAGS needs SYSCAP_RESTRICTEDROOT, if.c:2135); leak rate up to ~128KB/cycle at mtu 65535. Non-overlapping with DF-2000 (MTU-change UAF race) and DF-2001 (NULL deref): this is the steady-state down/up lifecycle leak. Guest reset to clean-source snapshot after validation. One uncharacterized observation: a vm.sh clean-shutdown hung (DDB suspected) after the leak demo with modules loaded; console log was overwritten by the next boot, so it is recorded as an observation only, not part of this finding.", "recommended_fix": "In icioctl SIOCSIFFLAGS up-branch, allocate ic_obuf/ic_ifbuf only if the pointer is NULL (reuse the pair retained across down), per fix.diff.", "fix_status": "fixed", "fix_baseline_reproduced": 1, "fix_patched_reproduced": 0, "fix_verdict": "Patched if_ic.ko (fix.diff) rebuilt and installed on the guest; the exact baseline workload (200 down/up cycles) no longer leaks: M_DEVBUF InUse stays 219 allocs / 214K before and after (baseline unfixed: +400 allocs / +600K).", "fix_evidence": "run.log FIX VALIDATION section (FIX-CYCLES-DONE); build.log.fix note in build.log" } |