From: Dimitris Charisis <dchar@cslab.ece.ntua.gr>
To: Florian Schmaus <florian.schmaus@codasip.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"Liam R. Howlett" <liam@infradead.org>,
Alice Ryhl <aliceryhl@google.com>,
Andrew Ballance <andrewjballance@gmail.com>,
Suren Baghdasaryan <surenb@google.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
maple-tree@lists.infradead.org, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/2] test_maple_tree: test maple_range_64 node in RCU mode
Date: Sat, 24 Oct 2026 14:26:47 +0300 [thread overview]
Message-ID: <5c05a17b-167e-4379-82f0-dbdff783d050@cslab.ece.ntua.gr> (raw)
In-Reply-To: <179276488829.1655926.9998832837982828676.b4-review@b4>
On 10/23/26 17:14, Florian Schmaus wrote:
>> This commit adds a test that builds two maple_range_64 trees in RCU
>> mode. The first tree has a root that is a full maple_range_64 node and
>> ensures that the destruction under RCU does not misinterpret the last
>> slot as metadata. 226 insertions produce such a root on a 64-bit build.
>>
>> The second tree is a height 3 tree whose root holds 15 child pointers
>> and metadata in its last slot, so every slot is non-zero and ensures
>> that the destruction under RCU does not descend into the metadata slot.
>> 3166 insertions produce such a tree on a 64-bit build.
>>
>> Signed-off-by: Dimitris Charisis <dchar@cslab.ece.ntua.gr>
>>
>> diff --git a/lib/test_maple_tree.c b/lib/test_maple_tree.c
>> index b9367c61e8b5..fb40e193a3cb 100644
>> --- a/lib/test_maple_tree.c
>> +++ b/lib/test_maple_tree.c
>> @@ -3710,6 +3710,36 @@ static noinline void __init alloc_cyclic_testing(struct maple_tree *mt)
>> MT_BUG_ON(mt, ret != 1);
>> }
>>
>> +static noinline void __init check_range64_in_rcu(struct maple_tree *mt)
>> +{
>> + unsigned long i;
>> + unsigned long nr_entries = 226; /* Build a full maple_range_64 root node */
>> +
>> + MT_BUG_ON(mt, !mtree_empty(mt));
>> + mt_init_flags(mt, MT_FLAGS_USE_RCU);
>> +
>> + for (i = 0; i < nr_entries; i++) {
>> + MT_BUG_ON(mt, mtree_test_insert_range(mt, i*10, i*10 + 9,
>> + xa_mk_value(i)));
>> + }
>> +
>> + mtree_destroy(mt);
>> + rcu_barrier();
>> +
>> + nr_entries = 3166; /* Height 3. Root has 15 children + metadata */
>> +
>> + MT_BUG_ON(mt, !mtree_empty(mt));
>> + mt_init_flags(mt, MT_FLAGS_USE_RCU);
>> +
>> + for (i = 0; i < nr_entries; i++) {
>> + MT_BUG_ON(mt, mtree_test_insert_range(mt, i*10, i*10 + 9,
>> + xa_mk_value(i)));
>> + }
>> +
>> + mtree_destroy(mt);
>> + rcu_barrier();
> This case passes on an unfixed kernel.
>
> The bug that exists today requires a non-root node with 15 children and a
> tree of height 4. The size-2768 test case in my series covers that. You can
> find my test at
>
> https://lore.kernel.org/all/20261015-maple-tree-fix-slab-corruption-v1-3-160d97f7304c@codasip.com/
>
> and may fold it into your check_range64_in_rcu(). It fails without your (or
> my) fix and succeed with.
Hi Florian!
KASAN catches the invalid pointer access in the first tested tree on
an unmodified kernel. The second test guards against the cause of the
second bug: a node (at least) two levels above the leaves with exactly
15 valid child pointers.
That being said, I do think that covering the case where this is an
intermediate node has its own value. After all, more testing is never
bad :-). Feel free to send / extend the test. Since it exercises the
same underlying issue, extending check_range64_in_rcu() seems like
the right place to me.
Dimitris
next prev parent reply other threads:[~2026-10-24 11:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-05 12:47 [PATCH v3 0/2] maple_tree: fix maple_range_64 crashes " Dimitris Charisis
2026-10-05 12:47 ` [PATCH v3 1/2] " Dimitris Charisis
2026-10-23 14:14 ` Florian Schmaus
2026-10-05 12:47 ` [PATCH v3 2/2] test_maple_tree: test maple_range_64 node " Dimitris Charisis
2026-10-23 14:14 ` Florian Schmaus
2026-10-24 11:26 ` Dimitris Charisis [this message]
2026-10-20 12:57 ` [PATCH v3 0/2] maple_tree: fix maple_range_64 crashes " Liam R. Howlett
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=5c05a17b-167e-4379-82f0-dbdff783d050@cslab.ece.ntua.gr \
--to=dchar@cslab.ece.ntua.gr \
--cc=akpm@linux-foundation.org \
--cc=aliceryhl@google.com \
--cc=andrewjballance@gmail.com \
--cc=florian.schmaus@codasip.com \
--cc=liam@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=maple-tree@lists.infradead.org \
--cc=surenb@google.com \
--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
all inboxes | Powered by JetHome®