Re: [PATCH 03/11] mm/mempolicy: reject migrate_pages source IDs beyond nr_node_ids

From: David Hildenbrand (Arm)

Date: Tue Dec 01 2026 - 05:02:57 EST


On 11/30/26 20:44, Gregory Price (Meta) wrote:
> On 2026-11-27 18:01 -0500, Yury Norov wrote:
>> The runtime nodemask conversion limits source iteration and weight
>> calculations in do_migrate_pages() to the runtime node range. Reject
>> userspace source masks containing node IDs at or above nr_node_ids
>> instead of silently ignoring those bits during migration selection.
>>
>
> So previously a migrate_pages() call with:
> nr_node_ids = 2
> possible_nodes = {0,1}
> source_nodes = {0,65}
> dest_nodes = {1}
>
> Would have successfully migrated memory from node0 to node1, and
> this change now returns -EINVAL.
>
>> Check the full MAX_NUMNODES-wide mask after copying old_nodes and return
>> -EINVAL if any source bit lies outside the runtime range. Keep the
>> existing destination permission checks and the do_migrate_pages() API.
>
> Can we just strip those nodes from 'old' instead? That would keep
> userspace behavior the same.

I'd prefer that as well.

--
Cheers,

David