Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2018-10-15 12:55:54 +0200
committerVlastimil Babka <vbabka@suse.cz>2018-10-15 12:55:54 +0200
commit6cf1086fd9e09934b30525e56c6f0a15f4748048 (patch)
treead59b2f0fdae4bde62a0132c5e7d7333c44aab74
parent5db1aea15b4ff9fb1ffdcbb8975c3210c432a3a1 (diff)
ksm: fix unlocked iteration over vmas in cmp_and_merge_page()
(VM Functionality bsc#1111806).
-rw-r--r--patches.fixes/ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch52
-rw-r--r--series.conf1
2 files changed, 53 insertions, 0 deletions
diff --git a/patches.fixes/ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch b/patches.fixes/ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch
new file mode 100644
index 0000000000..fc9e645a91
--- /dev/null
+++ b/patches.fixes/ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch
@@ -0,0 +1,52 @@
+From: Kirill Tkhai <ktkhai@virtuozzo.com>
+Date: Tue, 3 Oct 2017 16:14:27 -0700
+Subject: ksm: fix unlocked iteration over vmas in cmp_and_merge_page()
+Git-commit: 4b22927f0cbd58303aac689e378d20bf56267a39
+Patch-mainline: v4.14-rc4
+References: VM Functionality bsc#1111806
+
+In this place mm is unlocked, so vmas or list may change. Down read
+mmap_sem to protect them from modifications.
+
+Link: http://lkml.kernel.org/r/150512788393.10691.8868381099691121308.stgit@localhost.localdomain
+Fixes: e86c59b1b12d ("mm/ksm: improve deduplication of zero pages with colouring")
+Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
+Acked-by: Michal Hocko <mhocko@suse.com>
+Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
+Cc: Minchan Kim <minchan@kernel.org>
+Cc: zhong jiang <zhongjiang@huawei.com>
+Cc: Ingo Molnar <mingo@kernel.org>
+Cc: Claudio Imbrenda <imbrenda@linux.vnet.ibm.com>
+Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
+Cc: Hugh Dickins <hughd@google.com>
+Cc: <stable@vger.kernel.org>
+Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
+Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
+Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
+---
+ mm/ksm.c | 5 ++++-
+ 1 file changed, 4 insertions(+), 1 deletion(-)
+
+--- a/mm/ksm.c
++++ b/mm/ksm.c
+@@ -1436,6 +1436,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;
+@@ -1500,9 +1501,11 @@ static void cmp_and_merge_page(struct pa
+ if (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.
diff --git a/series.conf b/series.conf
index 9cd07343e3..759dcba424 100644
--- a/series.conf
+++ b/series.conf
@@ -7172,6 +7172,7 @@
patches.fixes/cgroup-Reinit-cgroup_taskset-structure-before-cgroup_migrate_execute-returns.patch
patches.fixes/lsm-fix-smack_inode_removexattr-and-xattr_getsecurit.patch
patches.arch/include-linux-mm.h-fix-typo-in-VM_MPX-definition.patch
+ patches.fixes/ksm-fix-unlocked-iteration-over-vmas-in-cmp_and_merge_page.patch
patches.suse/0001-mm-oom_reaper-skip-mm-structs-with-mmu-notifiers.patch
patches.fixes/mm-compaction-serialize-waitqueue_active-checks-for-real.patch
patches.fixes/mm-meminit-mark-init_reserved_page-as-__meminit.patch