Re: [PATCH v5 23/36] mm/mempolicy: apply policy at the kernel zone for private-node binds

[email protected] Tue, 21 Jul 2026 19:39:20 +0000
Newsgroups dev.linux.lists.nvdimm,dev.linux.lists.damon,org.kernel.vger.kvm,org.kernel.vger.linux-cxl
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] The `policy_private_has_kernel_zone()` function incorrectly skips checking `ZONE_DMA` and `ZONE_DMA32`, which causes mempolicy bypass for private nodes possessing only lower-zone memory.
--

--- Patch [23]: [PATCH v5 23/36] mm/mempolicy: apply policy at the kernel zone for private-node binds ---
commit 04782bb72086af5fe29a7dbf4184affd04c79df6
Author: Gregory Price <[email protected]>

mm/mempolicy: apply policy at the kernel zone for private-node binds

This commit introduces policy_private_has_kernel_zone() to prevent mempolicy
bypass when private nodes have non-movable memory.

> diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> index 90110e9761122..e83c2c7a94c1d 100644
> --- a/mm/mempolicy.c
> +++ b/mm/mempolicy.c
[ ... ]
> @@ -2091,6 +2091,34 @@ bool vma_policy_mof(struct vm_area_struct *vma)
[ ... ]
> +static bool policy_private_has_kernel_zone(const struct mempolicy *pol)
> +{
> +	int nid;
> +
> +	if (!(pol->flags & MPOL_F_PRIVATE))
> +		return false;
> +
> +	for_each_node_mask(nid, pol->nodes) {
> +		pg_data_t *pgdat = NODE_DATA(nid);
> +		enum zone_type zt;
> +
> +		if (!node_is_private(nid))
> +			continue;
> +		for (zt = ZONE_NORMAL; zt < ZONE_MOVABLE; zt++)

[Severity: Medium]
Does this loop miss checking ZONE_DMA and ZONE_DMA32 by starting at
ZONE_NORMAL?

If a user process sets a mempolicy binding to a private NUMA node that only
contains memory in ZONE_DMA or ZONE_DMA32, this loop will return false
because it skips those populated lower zones.

This would cause apply_policy_zone() to incorrectly raise
dynamic_policy_zone to ZONE_MOVABLE, resulting in kernel allocations
falling back to other system nodes and bypassing the policy intent.

> +			if (managed_zone(&pgdat->node_zones[zt]))
> +				return true;
> +	}
> +	return false;
> +}

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=23