DF-4752 / verdict.json
{ "finding_id": "DF-4752", "status": "inconclusive", "reproduced": 0, "impact": "leak", "confidence": "certain", "verdict": "Source-certain defect: gpio_unregister (gpio.c:587-617) never returns the master devices DEVFS_CLONE_BITMAP(gpio) unit (allocated at gpio.c:573 for the gpio/<drv>N/master cdev) and never frees the shared struct gpio_driver + kstrdupd name, unlinking it at gpio.c:609-611 even while sibling controllers of the same driver_name still reference it. Permanent privileged-trigger kernel heap leak per controller detach cycle; bitmap auto-extends (limit=0) so it is unbounded creep, not exhaustion. Distinct from known DF-1845 (pin-loop get-vs-put) and DF-1846. Runtime reproduction is hardware/kernel-config-gated: the gpio(4) framework is optional gpio (sys/conf/files:2119), absent from the guests X86_64_GENERIC (no /dev/gpio*, no module), so the trigger could not be executed on the audit guest; fix.diff compile-validated as a KLD module with -Werror on the guest (fix_build.log rc=0).", "exploit_chain": "", "evidence": "VERDICT.md (source trace with path:line); run.log (guest feature-absence markers); build.log vs fix_build.log (baseline and patched both rc=0, -Werror); fix.diff (refs + master-unit put + kfree on last ref)", "kernel_refs": [ "sys/dev/misc/gpio/gpio.c:573", "sys/dev/misc/gpio/gpio.c:602", "sys/dev/misc/gpio/gpio.c:609-611", "sys/vfs/devfs/devfs_helper.c:devfs_clone_bitmap_get" ], "poc_changes": "No seed PoC existed; trigger.sh authored fresh and honestly exits SKIP=3 on guests without the gpio(4) framework.", "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": "cd /root/gpiobuild/fix && make (KMOD= gpiotest SRCS= gpio.c, bsd.kmod.mk)", "run_cmd": "sh run.sh / trigger.sh", "code_hash": "", "notes": "Phase V effort concentrated on (1) proving the leak accounting across register/unregister by whole-function source trace incl. devfs_clone_bitmap_get limit semantics, and (2) -Werror compile validation of the fix on the guest kernel source. Guest /usr/src restored to pristine (sha256 verified) afterwards.", "recommended_fix": "Put the master clone unit back after destroy_dev; refcount struct gpio_driver and kfree gpd+name when the last same-name controller unregisters.", "fix_status": "inconclusive", "fix_baseline_reproduced": 0, "fix_patched_reproduced": 0, "fix_verdict": "fix.diff compiles clean as a KLD module (-Werror, rc=0) against guest 6.5-DEVELOPMENT source. Behavioral validation (unit returned, gpd freed, siblings safe) requires gpio(4) hardware absent from this guest.", "fix_evidence": "fix_build.log (patched module link line + rc=0); build.log (baseline rc=0); fix.diff" } |