From: Alejandro Lucero Palau <alucerop@amd.com>
To: Richard Cheng <icheng@nvidia.com>
Cc: alejandro.lucero-palau@amd.com, linux-cxl@vger.kernel.org,
linux-acpi@vger.kernel.org, rafael@kernel.org
Subject: Re: [RFC PATCH v1 1/1] acpi/hmat: preserve hmat_adist_nb notifier block
Date: Wed, 15 Jul 2026 15:47:00 +0100 [thread overview]
Message-ID: <686006af-a9cf-41e0-b245-e81a722b13f3@amd.com> (raw)
In-Reply-To: <ak74Kzuf6g9z9pOr@MWDK4CY14F>
On 7/9/26 02:37, Richard Cheng wrote:
> On Mon, Jul 06, 2026 at 07:57:09AM +0800, Alejandro Lucero Palau wrote:
>> On 7/2/26 08:20, Richard Cheng wrote:
>>> On Tue, Jun 30, 2026 at 03:35:07PM +0800, alejandro.lucero-palau@amd.com wrote:
>>>> From: Alejandro Lucero <alucerop@amd.com>
>>>>
>>>> Remove __meminitdata from hmat_adist_nb declaration preserving it even
>>>> when CONFIG_MEMORY_HOTPLUG is not set. Otherwise further notifier
>>>> registrations using register_mt_adistance_algorithm() will find a
>>>> notifier chain likely corrupted. This is the case when a CXL Type2
>>>> driver will load after kernel initialization and a CXL region created from
>>>> its committed HDM decoders registers an mt_adistance_algorithm notifier.
>>>>
>>>> Signed-off-by: Alejandro Lucero <alucerop@amd.com>
<snip>
>>>>
>>>> Not sure what you mean here. The way I understand your comment leads to
>>>> contradictions ...
>>>>
>>>>
>>>> "keep unconditional removal" suggest to me unregistering hmat_adist_nb but
>>>> "keep" confuses me as it is not unregister now only memory released based on
>>>> __meminitdata ... but maybe you mean exactly what I did and avoid any change
>>>> to __meminitdata declaration based on a config attribute, what is what Dave
>>>> is suggesting to explore.
>>>>
>>>>
>>>> Please, could you clarify this?
>>>>
> Sorry for the ambiguity, and yes, the last reading is what I meant.
> I mean your patch's removal of the "__meminitdata", not unregistering
> the notifier.
> I think it would be better not to replace it with a conditional macro.
>
> To be more clear about what I understand,
> 1. with MEMORY_HOTPLUG=n, "__meminitdata == __initdata", so hmat_adist_nb
> lives in ".init.data"
> 2. hmat_init() registers it, the mt_adistance_algorithms chain will hold a pointer to it, nothing ever unregister it.
> 3. When boot finishes, free_initmem() discards all ".init.data". The chain still points at that freed memory.
> 4. Any later register_mt_adistance_algorithm() call walks the chain and deref that stale pointer , causing use-after-free
>
> Note that, register_mt_adistance_algorithm() is an exported API, so any module
> loaded at runtime can trigger it, not only CXL. Dropping __meminitdata
> unconditionally closes the use-after-free for all caller, and the cost is just
> one notifier_block staying resident.
>
> Hope this clarify my point.
Hi Richard,
Yes, this is clear now.
I will send a v2 adding the Fixes tag and your point about the problem
not limited to MEMORY_HOTPLUG config.
Thanks!
prev parent reply other threads:[~2026-07-15 14:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-30 14:35 [RFC PATCH v1 0/1] Fix hmat_adist_nb for coming CXL Type2 alejandro.lucero-palau
2026-06-30 14:35 ` [RFC PATCH v1 1/1] acpi/hmat: preserve hmat_adist_nb notifier block alejandro.lucero-palau
2026-06-30 13:51 ` sashiko-bot
2026-06-30 16:18 ` Dave Jiang
2026-07-02 7:20 ` Richard Cheng
2026-07-06 6:57 ` Alejandro Lucero Palau
2026-07-09 1:37 ` Richard Cheng
2026-07-15 14:47 ` Alejandro Lucero Palau [this message]
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=686006af-a9cf-41e0-b245-e81a722b13f3@amd.com \
--to=alucerop@amd.com \
--cc=alejandro.lucero-palau@amd.com \
--cc=icheng@nvidia.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-cxl@vger.kernel.org \
--cc=rafael@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox