]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: enable maple tree RCU mode by default. maple_rcu
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 27 Feb 2023 17:36:07 +0000 (09:36 -0800)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 24 Mar 2023 15:18:38 +0000 (11:18 -0400)
commite34462a99a8408558e9adbdae6e9c27c54980e08
tree9a9f8804a23ccf90a21e5cb3e2436d4079cb6572
parent401dfa4bbec8f6f4fbf74d8ea2b4195479fc8084
mm: enable maple tree RCU mode by default.

Use the maple tree in RCU mode for VMA tracking.

The maple tree tracks the stack and is able to update the pivot
(lower/upper boundary) in-place to allow the page fault handler to write
to the tree while holding just the mmap read lock.  This is safe as the
writes to the stack have a guard VMA which ensures there will always be
a NULL in the direction of the growth and thus will only update a pivot.

It is possible, but not recommended, to have VMAs that grow up/down
without guard VMAs.  syzbot has constructed a testcase which sets up a
VMA to grow and consume the empty space.  Overwriting the entire NULL
entry causes the tree to be altered in a way that is not safe for
concurrent readers; the readers may see a node being rewritten or one
that does not match the maple state they are using.

Enabling RCU mode allows the concurrent readers to see a stable node and
will return the expected result.

Link: https://lkml.kernel.org/r/20230227173632.3292573-9-surenb@google.com
Link: https://lore.kernel.org/linux-mm/000000000000b0a65805f663ace6@google.com/
Cc: stable@vger.kernel.org
Fixes: d4af56c5c7c6 ("mm: start tracking VMAs with maple tree")
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
Reported-by: syzbot+8d95422d3537159ca390@syzkaller.appspotmail.com
include/linux/mm_types.h
kernel/fork.c
mm/mmap.c