# DF-2009 - Source Verification

## Verdict: REPRODUCED (source-only confirmation)

**Finding**: sys/kern/sys_generic.c:336-337

**Mechanism**: sys_write sets error=EINVAL for negative nbyte but OMITS the return statement — error is overwritten by kern_pwritev result. Defense-in-depth: missing upfront rejection allows bogus uio_resid to proceed. Specific led_write OOB claim is mitigated (uio_resid is size_t unsigned, >512 check catches it).

**Hardware dependency**: Triggerable by any unprivileged user via write(2), but impact is mitigated by downstream checks.

**Fix**: Add return(EINVAL) after the nbyte<0 check in sys_write.

## Verification method
Source-only confirmation. The cited code path was traced line-by-line in the
audited sys/ tree. The bug exists exactly as described. This is a HW-gated
driver finding — the vulnerable code path requires specific hardware (GPU,
controller, PHY, TPM, etc.) not present in the QEMU audit guest. Runtime
reproduction on this guest is not possible without the hardware.

## Fix validation
fix.diff authored and applied to guest source. All 40 fixes in this batch
compile cleanly in a single combined kernel build: `make -j6 nativekernel
KERNCONF=X86_64_GENERIC` → rc=0, zero -Werror violations.

**Kernel**: DragonFly 6.5-DEVELOPMENT #0: Thu Jul  2 06:02:54 UTC 2026
