From: sashiko-bot@kernel.org
To: "Gregory Price" <gourry@gourry.net>
Cc: linux-cxl@vger.kernel.org, nvdimm@lists.linux.dev
Subject: Re: [PATCH v7 03/10] mm/memory_hotplug: pass online_type to online_memory_block() via arg
Date: Sun, 12 Jul 2026 15:53:49 +0000 [thread overview]
Message-ID: <20260712155349.7294D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260712154505.3564379-4-gourry@gourry.net>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Incomplete refactoring introduces a TOCTOU race condition where `add_memory_resource` uses a stale snapshot of `online_type` but evaluates the condition using the live `mhp_get_default_online_type()`.
--
--- Patch [3]: [PATCH v7 03/10] mm/memory_hotplug: pass online_type to online_memory_block() via arg ---
commit 72fc58e4b65f508d5057e9fe2ec0ff1c08b34e61
Author: Gregory Price <gourry@gourry.net>
mm/memory_hotplug: pass online_type to online_memory_block() via arg
Modify online_memory_block() to accept the online type through its arg
parameter rather than calling mhp_get_default_online_type() internally.
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 7ac19fab22632..6833208cc17cb 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1494,6 +1496,7 @@ static int create_altmaps_and_memory_blocks(int nid, struct memory_group *group,
> int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
> {
> struct mhp_params params = { .pgprot = pgprot_mhp(PAGE_KERNEL) };
> + enum mmop online_type = mhp_get_default_online_type();
> enum memblock_flags memblock_flags = MEMBLOCK_NONE;
> struct memory_group *group = NULL;
> u64 start, size;
[ ... ]
> @@ -1582,7 +1585,8 @@ int add_memory_resource(int nid, struct resource *res, mhp_t mhp_flags)
>
> /* online pages if requested */
> if (mhp_get_default_online_type() != MMOP_OFFLINE)
> - walk_memory_blocks(start, size, NULL, online_memory_block);
> + walk_memory_blocks(start, size, &online_type,
> + online_memory_block);
[Severity: High]
Does checking the live state here instead of the cached online_type introduce
a race condition?
If a concurrent write to the lockless sysfs attribute
/sys/devices/system/memory/auto_online_blocks changes the global policy
from MMOP_OFFLINE to MMOP_ONLINE_MOVABLE while add_memory_resource() is
executing, this condition could evaluate to true while walk_memory_blocks()
uses the cached MMOP_OFFLINE value.
Because the condition uses the live value, but walk_memory_blocks() uses the
cached online_type, could memory_subsys_online() treat MMOP_OFFLINE as an
unconfigured request and forcefully overwrite it to MMOP_ONLINE?
This would result in memory being onlined into the un-removable ZONE_NORMAL
kernel zone instead of being left offline or onlined into ZONE_MOVABLE. This
pins the memory permanently and prevents memory hot-unplug, leading to
resource stranding in virtualized environments.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260712154505.3564379-1-gourry@gourry.net?part=3
next prev parent reply other threads:[~2026-07-12 15:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-12 15:44 [PATCH v7 00/10] dax/kmem: atomic whole-device hotplug via sysfs Gregory Price
2026-07-12 15:44 ` [PATCH v7 01/10] mm/memory: add memory_block_aligned_range() helper Gregory Price
2026-07-12 15:52 ` sashiko-bot
2026-07-12 15:44 ` [PATCH v7 02/10] mm/memory_hotplug: add mhp_online_type_to_str() and export string helpers Gregory Price
2026-07-12 15:44 ` [PATCH v7 03/10] mm/memory_hotplug: pass online_type to online_memory_block() via arg Gregory Price
2026-07-12 15:53 ` sashiko-bot [this message]
2026-07-12 15:44 ` [PATCH v7 04/10] mm/memory_hotplug: export mhp_get_default_online_type Gregory Price
2026-07-12 15:56 ` sashiko-bot
2026-07-12 15:44 ` [PATCH v7 05/10] mm/memory_hotplug: add __add_memory_driver_managed() with online_type arg Gregory Price
2026-07-12 15:45 ` [PATCH v7 06/10] mm/memory_hotplug: add offline_and_remove_memory_ranges() Gregory Price
2026-07-12 15:53 ` sashiko-bot
2026-07-12 15:45 ` [PATCH v7 07/10] dax/kmem: resolve default online type at probe time Gregory Price
2026-07-12 15:56 ` sashiko-bot
2026-07-12 15:45 ` [PATCH v7 08/10] dax/kmem: extract hotplug/hotremove helper functions Gregory Price
2026-07-12 15:54 ` sashiko-bot
2026-07-12 15:45 ` [PATCH v7 09/10] dax/kmem: add sysfs interface for atomic whole-device hotplug Gregory Price
2026-07-12 15:45 ` [PATCH v7 10/10] selftests/dax: add dax/kmem hotplug sysfs regression test Gregory Price
2026-07-12 16:48 ` [PATCH v7 00/10] dax/kmem: atomic whole-device hotplug via sysfs Gregory Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260712155349.7294D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=gourry@gourry.net \
--cc=linux-cxl@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.