Re: [PATCH] selftests: net: reuseport_bpf_numa: consider cpuless numa node

Feng Tang <[email protected]> Sun, 2 Aug 2026 15:47:46 +0800
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf
Message-ID <[email protected]>
On Fri, Jul 31, 2026 at 12:59:23PM -0700, Andi Kleen wrote:
> > > Will this crash if numa_allocate_cpumask() fails to allocate memory?
> > > 
> > > It looks like cpumask could be NULL here, which is passed directly to
> > > numa_node_to_cpus() and numa_bitmask_weight() without validation.
> >  
> > Good point. 
> > 
> > If the allocation fail, will return 'false' to let the code go the
> > original flow.
> 
> 
> While it's technically true, checking for out of memory in ring 3
> (or at least other checking than exit(1) on error) is usually 
> useless. Most of the time when this would fail you're as likely
> to just get killed by the OOM killer, as well as the harness that
> called you. Maybe it could happen without that with some very tight
> ulimit settings, but with that not much else will work anyways.
> Also these paths are basically never exercised so likely buggy
> when non trivial.

Good point.

> 
> For libnuma if you set numa_exit_on_error to 1 it will always
> exiting after printing an error. That includes the allocation
> functions.
 
Good to know that!

> 
> 
> > > > +		ret = true;
> > > 
> > > [Severity: Medium]
> > > What happens if numa_node_to_cpus() fails?
> > > 
> > > It can return a negative error value, leaving the cpumask unmodified with
> > > zero bits set. Because the return value is not checked,
> > > numa_bitmask_weight(cpumask) will evaluate to 0. Does this cause the function
> > > to return true and silently skip testing on nodes where an error occurs,
> > > rather than reporting the infrastructure issue?
> > 
> > From the code logic (with above change), the 'node_id' and 'cpumask' have
> > both been validated, and this numa_node_to_cpus() is very unlikely to fail
> > here upon reading libnuma source code.
> 
> Yes it's unlikely to fail.
 
Thanks for confirming it!

- Feng

> -Andi