From: Andrew Morton <akpm@linux-foundation.org>
To: Boudewijn van der Heide <boudewijn@delta-utec.com>
Cc: "Liam R . Howlett" <Liam.Howlett@oracle.com>,
Alice Ryhl <aliceryhl@google.com>,
Andrew Ballance <andrewjballance@gmail.com>,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] maple_tree: Add dead node check in mas_dup_alloc()
Date: Sat, 3 Jan 2026 10:32:47 -0800 [thread overview]
Message-ID: <20260103103247.9140cb2556280927b09f59d3@linux-foundation.org> (raw)
In-Reply-To: <20260103165758.74094-1-boudewijn@delta-utec.com>
On Sat, 3 Jan 2026 17:57:58 +0100 Boudewijn van der Heide <boudewijn@delta-utec.com> wrote:
> The __mt_dup() function is exported and can be called without internal
> locking, relying on the caller to provide appropriate synchronization.
> If a caller fails to hold proper locks, the source tree may be modified
> concurrently, potentially resulting in dead nodes during traversal.
>
> The call stack is:
> __mt_dup()
> → mas_dup_build()
> → mas_dup_alloc() [accesses node->slot[]]
>
> The mas_dup_alloc() function may access node slots without first
> verifying that the node is still alive. If a dead node is encountered,
> its memory layout may have been switched to the RCU union member, making
> slot array access undefined behavior as we would be reading from the
> rcu_head structure instead.
>
> Add an explicit dead node check to detect concurrent modification during
> duplication. When a dead node is detected, return -EBUSY to indicate that
> the tree is undergoing concurrent modification.
>
> Signed-off-by: Boudewijn van der Heide <boudewijn@delta-utec.com>
>
> ---
>
> Build-tested and boot-tested with QEMU with Buildroot on x86_64. The
> kernel booted and basic commandline operations work correctly. The race
> condition this patch addresses is difficult to reproduce in testing, as
> it requires concurrent tree modifications without proper locking.
Thanks.
What are the worst-case userspace-visible runtime effects when this
happens?
If they're bad then presumably we'll want to backport this fix into
earlier kernels with a Cc: <stable@vger.kernel.org> and, very
preferably a Fixes: line.
next prev parent reply other threads:[~2026-01-03 18:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-03 16:57 Boudewijn van der Heide
2026-01-03 18:32 ` Andrew Morton [this message]
2026-01-03 20:06 ` Boudewijn van der Heide
2026-01-06 1:33 ` Andrew Morton
2026-01-06 2:49 ` Matthew Wilcox
2026-01-06 3:40 ` Andrew Morton
2026-01-06 13:24 ` Boudewijn van der Heide
2026-01-06 16:01 ` Liam R. Howlett
2026-01-06 16:48 ` Boudewijn van der Heide
2026-01-06 18:29 ` Matthew Wilcox
2026-01-06 20:07 ` Liam R. Howlett
2026-01-06 21:07 ` [PATCH v2] maple_tree: Add lockdep assertion " Boudewijn van der Heide
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=20260103103247.9140cb2556280927b09f59d3@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=Liam.Howlett@oracle.com \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=boudewijn@delta-utec.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.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