Patch "ksm: fix unlocked iteration over vmas in cmp_and_merge_page()" has been added to the 4.13-stable tree
This is a note to let you know that I've just added the patch titled
ksm: fix unlocked iteration over vmas in cmp_and_merge_page()
to the 4.13-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch
and it can be found in the queue-4.13 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
4b22927f0cbd58303aac689e378d20bf56267a39Mon Sep 17 00:00:00 2001
From: Kirill Tkhai <[email protected]>
Date: Tue, 3 Oct 2017 16:14:27 -0700
Subject: ksm: fix unlocked iteration over vmas in cmp_and_merge_page()
From: Kirill Tkhai <[email protected]>
commit 4b22927f0cbd58303aac689e378d20bf56267a39 upstream.
In this place mm is unlocked, so vmas or list may change. Down read mmap_sem to protect them from modifications.
--- mm/ksm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
mm/ksm.c +4 -1
@@ -1990,6 +1990,7 @@ static void stable_tree_append(struct rm*/ static void cmp_and_merge_page (struct page *page,struct rmap_item *rmap_item) { +struct mm_struct *mm = rmap_item->mm;struct rmap_item *tree_rmap_item;struct page *tree_page =NULL ;struct stable_node *stable_node;
@@ -2062,9 +2063,11 @@ static void cmp_and_merge_page(struct paif (ksm_use_zero_pages && (checksum == zero_checksum)) {struct vm_area_struct *vma; - vma =find_mergeable_vma (rmap_item->mm, rmap_item->address); +down_read (&mm->mmap_sem); + vma =find_mergeable_vma (mm, rmap_item->address); err =try_to_merge_one_page (vma, page,ZERO_PAGE (rmap_item->address)); +up_read (&mm->mmap_sem);/* * In case of failure, the page was not really empty, so we * need to continue. Otherwise we're done.
Patches currently in stable-queue which might be from [email protected] are
queue-4.13/ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch