Re: [PATCH 03/11] mm/mempolicy: reject migrate_pages source IDs beyond nr_node_ids
From: Yury Norov
Date: Tue Dec 01 2026 - 15:46:17 EST
On Tue, Dec 01, 2026 at 11:02:36AM +0100, David Hildenbrand (Arm) wrote:
> 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.
The nodes here are the actual nodes, not relative indexes like in the
following patch, so when user passes a non-existent node, that sounds
like an error to me.
The real question is: is there any userspace app relying on the
current behavior? If yes - we don't break userspace. If no, I'd
consider tightening the interface.
But anyways, interface changes are not the purpose of this series. So
if there are no objections, I'll simply drop the patch.