Skip to content

fix missing rb_subtree_gap updates on vma insert/erase

Michel Lespinasse linux-mm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 6 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3mm: ensure safe rb_subtree_gap update when inserting new VMAmm/mmap.c+15 -121 reply
2/3mm: ensure safe rb_subtree_gap update when removing VMAmm/mmap.c+3 -31 reply
3/3mm: debug code to verify rb_subtree_gap updates are safemm/mmap.c+55 -331 reply

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchRik van Riel
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/3] fix missing rb_subtree_gap updates on vma insert/erase

Using the trinity fuzzer, Sasha Levin uncovered a case where rb_subtree_gap wasn't correctly updated.

Digging into this, the root cause was that vma insertions and removals require both an rbtree insert or erase operation (which may trigger tree rotations), and an update of the next vma's gap (which does not change the tree topology, but may require iterating on the node's ancestors to propagate the update). The rbtree rotations caused the rb_subtree_gap values to be updated in some of the internal nodes, but without upstream propagation. Then the subsequent update on the next vma didn't iterate as high up the tree as it should have, as it stopped as soon as it hit one of the internal nodes that had been updated as part of a tree rotation.

The fix is to impose that all rb_subtree_gap values must be up to date before any rbtree insertion or erase, with the possible exception that the node being erased doesn't need to have an up to date rb_subtree_gap.

These 3 patches apply on top of the stack I previously sent (or equally, on top of the last published mmotm).

Michel Lespinasse (3):
mm: ensure safe rb_subtree_gap update when inserting new VMA
mm: ensure safe rb_subtree_gap update when removing VMA
mm: debug code to verify rb_subtree_gap updates are safe

 mm/mmap.c |  121 +++++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 73 insertions(+), 48 deletions(-)
Signature · 7 lines
1.7.7.3

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>