[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260106210757.465586-1-boudewijn@delta-utec.com>
Date: Tue, 6 Jan 2026 22:07:57 +0100
From: Boudewijn van der Heide <boudewijn@...ta-utec.com>
To: Liam.Howlett@...cle.com
Cc: boudewijn@...ta-utec.com,
akpm@...ux-foundation.org,
aliceryhl@...gle.com,
andrewjballance@...il.com,
linux-kernel@...r.kernel.org,
linux-mm@...ck.org,
maple-tree@...ts.infradead.org
Subject: [PATCH v2] maple_tree: Add lockdep assertion in mas_dup_alloc()
The __mt_dup() function requires callers to hold the appropriate write
lock when duplicating a maple tree. Without proper locking, concurrent
modifications during duplication could access invalid node slots.
Add a lockdep assertion to catch such API misuse during development.
This is API hardening rather than a bug fix - all in-tree callers
already follow the proper locking rules as documented above __mt_dup().
Signed-off-by: Boudewijn van der Heide <boudewijn@...ta-utec.com>
---
Changes in v2:
- Replaced runtime deadnode check with a lockdep assertion
v1:
https://lore.kernel.org/lkml/20260103165758.74094-1-boudewijn@delta-utec.com/
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 5aa4c9500018..3b4357f16352 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -6248,6 +6248,8 @@ static inline void mas_dup_alloc(struct ma_state *mas, struct ma_state *new_mas,
void __rcu **new_slots;
unsigned long val;
+ lockdep_assert(mt_write_locked(mas->tree));
+
/* Allocate memory for child nodes. */
type = mte_node_type(mas->node);
new_slots = ma_slots(new_node, type);
--
2.47.3
Powered by blists - more mailing lists