diff options
| author | Liam R. Howlett (Google) <liam@infradead.org> | 2026-11-02 21:07:22 -0500 |
|---|---|---|
| committer | Andrew Morton <akpm@linux-foundation.org> | 2026-11-09 22:44:30 -0800 |
| commit | e8a71f284ba7eeddd9475bb0b65200e95428b497 (patch) | |
| tree | 35a39745c4de654a8002d260d5fed56540cd0459 /tools | |
| parent | ff82ce7f90f52254029a73d12542c22e7e705aef (diff) | |
maple_tree: fix rcu reader NULL dereference after the tree is emptied
Patch series "maple_tree fixes for 7.3", v2.
Two bugs found by an LLM review, and one problem Lorenzo Stoakes
reported off list.
An RCU reader that restarts after its node dies can dereference NULL if
the tree was emptied, or holds a single entry in the root pointer.
Patch 1 fixes it and patch 2 adds a test.
With CONFIG_DEBUG_MAPLE_TREE, MT_WARN_ON() and the other WARN macros
print the tree and call dump_stack() rather than WARN(), so syzbot never
sees them. Patch 3 makes them WARN once per call site, after the dump,
and makes the BUG macros BUG() after theirs. The userspace tests make
WARN() fatal to keep failing as they did on dump_stack().
This patch (of 3):
RCU readers may hit a NULL dereference if the tree is emptied while the
walker is restarted from a dead node. Avoid the NULL dereference by
checking for an emptied/pointer tree (0->ptr, 1-ULONG_MAX -> NULL) and
set the maple state limits correctly.
A reader of /proc/<pid>/maps racing with an munmap() of the whole
address space can hit this. The first implementation has the same
problem in both directions.
Initial fix was generated by LLM and sent by Chris Mason in private.
[akpm@linux-foundation.org: fix reverse iterator state when the root disappears]
Link: https://lore.kernel.org/20261104104137.2058705ac29734a7ab5666c1@linux-foundation.org
Link: https://lore.kernel.org/20261103020724.2614498-1-liam@infradead.org
Link: https://lore.kernel.org/20261103020724.2614498-2-liam@infradead.org
Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett (Google) <liam@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Chris Mason <mason@kernel.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Alice Ryhl <aliceryhl@google.com>
Cc: Andrew Ballance <andrewjballance@gmail.com>
Cc: <stable@vger.kernel.org>
Diffstat (limited to 'tools')
0 files changed, 0 insertions, 0 deletions
