Skip to content

RFC ksm: fix use after free with merge_across_nodes = 0

Andrea Arcangeli linux-mm 1 version Applied

Status from this message: [merged] ksm-fix-use-after-free-with-merge_across_nodes-=-0.patch removed from -mm tree

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest1 patch 2 repliesApplied 1/1

Patches in v1 All 1 applied

#Subject and filesSizeRepliesApplied
1/1ksm: fix use after free with merge_across_nodes = 0mm/ksm.c+55 -111 replyApplied

Reviews trailers per patch

The patch has no Reviewed-by or Acked-by.

PatchPetr HolasekAndrey Ryabinin
SeriesT-b
1/1T-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 [RFC] [PATCH 0/1] ksm: fix use after free with merge_across_nodes = 0

Hello,

The KSMscale patch in -mm (not yet upstream) is fundamental for enterprise use and in turn it's included in -mm, RHEL, CentoOS and Ubuntu and it'd be great if it could be merged upstream (especially after solving this problem with merge_across_nodes = 0 ...).

https://marc.info/?l=linux-mm&m=149265809928003&w=2
http://kernel.ubuntu.com/~gavinguo/sf00131845/numa-131845.svg
http://kernel.ubuntu.com/~gavinguo/sf00131845/virtual_appliances_loading.png

A few weeks ago I got a report that with merge_across_nodes set to 0 KSM would eventually crash with an user after free (I assumed it was an use after free because the kindly provided crashdump showed a corrupted stable_node). Everything was again rock solid after setting merge_across_nodes back to 1.

merge_across_nodes set to 0 is a tuning performance optimization for NUMA that creates a different copy of KSM pages for each NUMA node with a KSM stable_tree for each node (instead of sharing the same equal memory across the whole system with a single stable_tree).

I couldn't reproduce this bug so far but there's a definitive use after free in the merge_across_nodes = 0 path, so it would help if who can reproduce already can give this a spin (untested... or better tested but only in a NUMA balancing environment that never reproduced the use after free in the first place so it's inconclusive).

In production I recommend to leave the merge_across_nodes default value set to 1 if running with the KSMscale patch applied for the time being, until this is confirmed fixed.

Again this fix should be considered untested so it should be run in testing environment only.

Thanks,
Andrea

Andrea Arcangeli (1):
ksm: fix use after free with merge_across_nodes = 0

 mm/ksm.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 55 insertions(+), 11 deletions(-)

--
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>