summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/linux/files/mm-2014-3122.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes-kernel/linux/files/mm-2014-3122.patch')
-rw-r--r--recipes-kernel/linux/files/mm-2014-3122.patch98
1 files changed, 0 insertions, 98 deletions
diff --git a/recipes-kernel/linux/files/mm-2014-3122.patch b/recipes-kernel/linux/files/mm-2014-3122.patch
deleted file mode 100644
index 590af0a..0000000
--- a/recipes-kernel/linux/files/mm-2014-3122.patch
+++ /dev/null
@@ -1,98 +0,0 @@
1From 77552735ba84a410447af7e3375625eb4cfd577b Mon Sep 17 00:00:00 2001
2From: Vlastimil Babka <vbabka@suse.cz>
3Date: Mon, 7 Apr 2014 15:37:50 -0700
4Subject: [PATCH] mm: try_to_unmap_cluster() should lock_page() before mlocking
5
6commit 57e68e9cd65b4b8eb4045a1e0d0746458502554c upstream.
7
8A BUG_ON(!PageLocked) was triggered in mlock_vma_page() by Sasha Levin
9fuzzing with trinity. The call site try_to_unmap_cluster() does not lock
10the pages other than its check_page parameter (which is already locked).
11
12The BUG_ON in mlock_vma_page() is not documented and its purpose is
13somewhat unclear, but apparently it serializes against page migration,
14which could otherwise fail to transfer the PG_mlocked flag. This would
15not be fatal, as the page would be eventually encountered again, but
16NR_MLOCK accounting would become distorted nevertheless. This patch adds
17a comment to the BUG_ON in mlock_vma_page() and munlock_vma_page() to that
18effect.
19
20The call site try_to_unmap_cluster() is fixed so that for page !=
21check_page, trylock_page() is attempted (to avoid possible deadlocks as we
22already have check_page locked) and mlock_vma_page() is performed only
23upon success. If the page lock cannot be obtained, the page is left
24without PG_mlocked, which is again not a problem in the whole unevictable
25memory design.
26
27Fixes CVE-2014-3122
28Upstream-Status: Backport
29
30Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
31Signed-off-by: Bob Liu <bob.liu@oracle.com>
32Reported-by: Sasha Levin <sasha.levin@oracle.com>
33Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com>
34Cc: Michel Lespinasse <walken@google.com>
35Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
36Acked-by: Rik van Riel <riel@redhat.com>
37Cc: David Rientjes <rientjes@google.com>
38Cc: Mel Gorman <mgorman@suse.de>
39Cc: Hugh Dickins <hughd@google.com>
40Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
41Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
42Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
43Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
44Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
45---
46 mm/mlock.c | 2 ++
47 mm/rmap.c | 14 ++++++++++++--
48 2 files changed, 14 insertions(+), 2 deletions(-)
49
50diff --git a/mm/mlock.c b/mm/mlock.c
51index 79b7cf7..713e462 100644
52--- a/mm/mlock.c
53+++ b/mm/mlock.c
54@@ -76,6 +76,7 @@ void clear_page_mlock(struct page *page)
55 */
56 void mlock_vma_page(struct page *page)
57 {
58+ /* Serialize with page migration */
59 BUG_ON(!PageLocked(page));
60
61 if (!TestSetPageMlocked(page)) {
62@@ -106,6 +107,7 @@ unsigned int munlock_vma_page(struct page *page)
63 {
64 unsigned int page_mask = 0;
65
66+ /* For try_to_munlock() and to serialize with page migration */
67 BUG_ON(!PageLocked(page));
68
69 if (TestClearPageMlocked(page)) {
70diff --git a/mm/rmap.c b/mm/rmap.c
71index 3f60774..fbf0040 100644
72--- a/mm/rmap.c
73+++ b/mm/rmap.c
74@@ -1390,9 +1390,19 @@ static int try_to_unmap_cluster(unsigned long cursor, unsigned int *mapcount,
75 BUG_ON(!page || PageAnon(page));
76
77 if (locked_vma) {
78- mlock_vma_page(page); /* no-op if already mlocked */
79- if (page == check_page)
80+ if (page == check_page) {
81+ /* we know we have check_page locked */
82+ mlock_vma_page(page);
83 ret = SWAP_MLOCK;
84+ } else if (trylock_page(page)) {
85+ /*
86+ * If we can lock the page, perform mlock.
87+ * Otherwise leave the page alone, it will be
88+ * eventually encountered again later.
89+ */
90+ mlock_vma_page(page);
91+ unlock_page(page);
92+ }
93 continue; /* don't unmap */
94 }
95
96--
971.9.1
98