src icon indicating copy to clipboard operation
src copied to clipboard

netmap: harden nmreq option size and overflow checks (defensive)

Open SORencber opened this issue 3 months ago • 3 comments

Summary: Enforce exact per‑option body size equality; add explicit overflow guards for size arithmetic; reject invalid lengths with EINVAL. Defensive hardening; no API break.

Test Plan: malformed NIOCCTRL (oversized nro_size, invalid types) → EINVAL/ENOTTY/ENXIO; no panic; valid flows unchanged.

Risk: Low; only invalid inputs are rejected earlier.

SORencber avatar Oct 03 '25 08:10 SORencber

hi @SORencber best open a request upstream (https://github.com/freebsd/freebsd-src / https://reviews.freebsd.org/) to avoid future breakage.

AdSchellevis avatar Oct 03 '25 09:10 AdSchellevis

Thanks for the guidance. I’ve submitted the defensive hardening upstream to FreeBSD (link to Differential on reviews.freebsd.org). Keeping this PR open until upstream is accepted, then we can align in OPNsense. No API change; single-file change in sys/dev/netmap/netmap.c

SORencber avatar Oct 03 '25 09:10 SORencber

Submitted upstream FreeBSD PR: netmap: harden nmreq option size and overflow checks (defensive) https://github.com/freebsd/freebsd-src/pull/1866 All CI checks passed; DCO signed. See upstream PR for details and CI results. Once merged (and MFC’d to stable/14), we can sync/vendor-pull into OPNsense. If upstream requests tweaks, I’ll mirror the same changes here. If desired, we can temporarily carry the patch downstream until the upstream merge lands.

SORencber avatar Oct 03 '25 11:10 SORencber