summaryrefslogtreecommitdiffstats
path: root/recipes-kernel
diff options
context:
space:
mode:
authorSona Sarmadi <sona.sarmadi@enea.com>2015-02-13 10:38:23 +0100
committerZhenhua Luo <zhenhua.luo@freescale.com>2015-03-06 16:28:07 +0800
commit252c07db20a389027565ae7558b4ecdc4f9d74e9 (patch)
tree2db89876c8da5f5eed08a7665556b70f49cde392 /recipes-kernel
parentd2c73b2d98a0b23987922a7396030ddbb57b93b3 (diff)
downloadmeta-fsl-ppc-252c07db20a389027565ae7558b4ecdc4f9d74e9.tar.gz
mm: CVE-2014-3122
try_to_unmap_cluster() should lock_page() before mlocking Reference: http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2014-3122 Signed-off-by: Sona Sarmadi <sona.sarmadi@enea.com>
Diffstat (limited to 'recipes-kernel')
-rw-r--r--recipes-kernel/linux/files/mm-2014-3122.patch98
-rw-r--r--recipes-kernel/linux/linux-qoriq_3.12.bb1
2 files changed, 99 insertions, 0 deletions
diff --git a/recipes-kernel/linux/files/mm-2014-3122.patch b/recipes-kernel/linux/files/mm-2014-3122.patch
new file mode 100644
index 0000000..590af0a
--- /dev/null
+++ b/recipes-kernel/linux/files/mm-2014-3122.patch
@@ -0,0 +1,98 @@
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
diff --git a/recipes-kernel/linux/linux-qoriq_3.12.bb b/recipes-kernel/linux/linux-qoriq_3.12.bb
index a65c458..7bf8b22 100644
--- a/recipes-kernel/linux/linux-qoriq_3.12.bb
+++ b/recipes-kernel/linux/linux-qoriq_3.12.bb
@@ -30,6 +30,7 @@ SRC_URI = "git://git.freescale.com/ppc/sdk/linux.git;nobranch=1 \
30 file://0001-ALSA-CVE-2014-4656.patch \ 30 file://0001-ALSA-CVE-2014-4656.patch \
31 file://0002-ALSA-CVE-2014-4656.patch \ 31 file://0002-ALSA-CVE-2014-4656.patch \
32 file://target-CVE-2014-4027.patch \ 32 file://target-CVE-2014-4027.patch \
33 file://mm-2014-3122.patch \
33" 34"
34SRCREV = "6619b8b55796cdf0cec04b66a71288edd3057229" 35SRCREV = "6619b8b55796cdf0cec04b66a71288edd3057229"
35 36