Re: [PATCH] niu: validate num_ports against NIU_MAX_PORTS

From: Jakub Kicinski

Date: Thu Aug 27 2026 - 15:16:42 EST


On Tue, 25 Aug 2026 17:42:42 +0800 Yang Zi wrote:
> niu_get_and_validate_port() obtains parent->num_ports from hardware
> (nr64(ESPC_NUM_PORTS_MACS) & ESPC_NUM_PORTS_MACS_VAL), an 8-bit value that
> can range from 0 to 255, with no upper-bound check.  The driver's per-port
> arrays (rxchan_per_port[], txchan_per_port[], rdc_group_cfg[]) are only
> NIU_MAX_PORTS (4) entries, so niu_divide_channels() and
> niu_divide_rdc_groups() iterate num_ports times and write out of bounds
> whenever num_ports is greater than 4.
>
> Reject num_ports > NIU_MAX_PORTS with -EINVAL so the probe aborts before any
> of these arrays are written.
>
> Covers fuzzing bug IDs 321, 322, 323 and 324 (same root cause).
>
> Signed-off-by: Yang Zi <2959243019@xxxxxx>

this is a waste of time, please don't send any more patches to linux
networking this year