Re: [PATCH] driver core: ensure a device has valid node id in device_add()

From: Peter Zijlstra
Date: Mon Sep 23 2019 - 11:09:58 EST


On Wed, Sep 11, 2019 at 08:49:26AM +0200, Michal Hocko wrote:
> On Wed 11-09-19 14:15:51, Yunsheng Lin wrote:

> > >>>>>> When passing the return value of dev_to_node() to cpumask_of_node()
> > >>>>>> without checking the node id if the node id is not valid, there is
> > >>>>>> global-out-of-bounds detected by KASAN as below:
> > >>>>>
> > >>>>> OK, I seem to remember this being brought up already. And now when I
> > >>>>> think about it, we really want to make cpumask_of_node NUMA_NO_NODE
> > >>>>> aware. That means using the same trick the allocator does for this
> > >>>>> special case.

> No. Please read the above paragraph again. NUMA_NO_NODE really means no
> node affinity. So all cpus should be usable. Making any assumptions
> about a local context is just wrong.

So none of this makes sense to me. How can a device have NUMA_NO_NODE on
a NUMA machine. It needs to have a physical presence _somwhere_; and
that cannot be equidistant from all CPUs.

Please explain how this makes physical sense.