From: "Liam R. Howlett" <Liam.Howlett@oracle.com>
To: Josh Law <objecting@objecting.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Alice Ryhl <aliceryhl@google.com>,
Andrew Ballance <andrewjballance@gmail.com>,
Matthew Wilcox <willy@infradead.org>,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/maple_tree: fix incorrect dead range comparison in mas_topiary_replace()
Date: Tue, 31 Mar 2026 23:20:17 -0400 [thread overview]
Message-ID: <gim5evcpgfrls3cy6ln7tuk6n33wvbsw4t6opxsbkluwab5smr@lqk2sxjzfkd5> (raw)
In-Reply-To: <20260317222925.87929-1-objecting@objecting.org>
* Josh Law <objecting@objecting.org> [260317 18:29]:
> When collecting old nodes for destruction, the dead range check uses
> tmp_next->index and tmp_next->last, which implicitly dereferences
> tmp_next[0] rather than the intended dead range. This means children
> at indices n=1 or n=2 are compared against the first child's state
> instead of the replacement range [mas->index, mas->last].
>
> This currently produces correct results by coincidence -- mas_find_child()
> copies the parent state and mas_descend() preserves index/last, so the
> values always equal mas->index/last. Fix it to use the canonical source
> directly, as documented: "Nodes within [index, last] are dead subtrees".
NACK
I'd rather reference the same struct if we're going to fix this and I'm
not wasting more time on any patches from objecting.
>
> Fixes: 54a611b60590 ("Maple Tree: add new data structure")
> Signed-off-by: Josh Law <objecting@objecting.org>
> ---
> lib/maple_tree.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/maple_tree.c b/lib/maple_tree.c
> index 1eaaa5f964e9..64ba117ec254 100644
> --- a/lib/maple_tree.c
> +++ b/lib/maple_tree.c
> @@ -1874,8 +1874,8 @@ static inline void mas_topiary_replace(struct ma_state *mas,
> if (!mas_find_child(&tmp[i], &tmp_next[n]))
> break;
>
> - if ((tmp_next[n].min >= tmp_next->index) &&
> - (tmp_next[n].max <= tmp_next->last)) {
> + if ((tmp_next[n].min >= mas->index) &&
> + (tmp_next[n].max <= mas->last)) {
> mat_add(&subtrees, tmp_next[n].node);
> tmp_next[n].status = ma_none;
> } else {
> --
> 2.34.1
>
>
> --
> maple-tree mailing list
> maple-tree@lists.infradead.org
> https://lists.infradead.org/mailman/listinfo/maple-tree
prev parent reply other threads:[~2026-04-01 3:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 22:29 Josh Law
2026-04-01 3:20 ` Liam R. Howlett [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=gim5evcpgfrls3cy6ln7tuk6n33wvbsw4t6opxsbkluwab5smr@lqk2sxjzfkd5 \
--to=liam.howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=objecting@objecting.org \
--cc=willy@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