Files
linux/lib
Liam R. Howlett (Google) e8a71f284b 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.

[[email protected]: fix reverse iterator state when the root disappears]
  Link: https://lore.kernel.org/[email protected]
Link: https://lore.kernel.org/[email protected]
Link: https://lore.kernel.org/[email protected]
Fixes: 54a611b605 ("Maple Tree: add new data structure")
Signed-off-by: Liam R. Howlett (Google) <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Reported-by: Chris Mason <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Alice Ryhl <[email protected]>
Cc: Andrew Ballance <[email protected]>
Cc: <[email protected]>
2026-11-09 22:44:30 -08:00
..
2026-08-13 15:42:05 -07:00
2025-03-16 22:30:49 -07:00
…
…
2025-04-11 17:32:37 -07:00
2026-03-05 22:16:08 -05:00
…
…
…
…
…
…
…
…
2026-10-06 19:02:51 -07:00
…
…
…
…
…
2026-07-31 10:09:12 +02:00
2024-10-14 16:33:24 -05:00
…
…
…
2026-02-27 16:40:16 +01:00
…
…
2025-03-25 10:18:31 -03:00
2026-04-18 00:10:48 -07:00
…
2024-12-09 13:48:29 -08:00