diff options
| author | Sona Sarmadi <sona.sarmadi@enea.com> | 2015-02-13 10:38:23 +0100 |
|---|---|---|
| committer | Zhenhua Luo <zhenhua.luo@freescale.com> | 2015-03-06 16:28:07 +0800 |
| commit | 68ab723ab6bb3e6055efad8c5682b21e86f1a1b9 (patch) | |
| tree | 27e2cbec2c84b384e6456136b5c8137b1908bfd4 | |
| parent | 0924bb79343a6846efa3acc8d14c2139b5abcec2 (diff) | |
| download | meta-freescale-68ab723ab6bb3e6055efad8c5682b21e86f1a1b9.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>
| -rw-r--r-- | meta-fsl-ppc/recipes-kernel/linux/files/mm-2014-3122.patch | 98 | ||||
| -rw-r--r-- | meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb | 1 |
2 files changed, 99 insertions, 0 deletions
diff --git a/meta-fsl-ppc/recipes-kernel/linux/files/mm-2014-3122.patch b/meta-fsl-ppc/recipes-kernel/linux/files/mm-2014-3122.patch new file mode 100644 index 000000000..590af0a69 --- /dev/null +++ b/meta-fsl-ppc/recipes-kernel/linux/files/mm-2014-3122.patch | |||
| @@ -0,0 +1,98 @@ | |||
| 1 | From 77552735ba84a410447af7e3375625eb4cfd577b Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Vlastimil Babka <vbabka@suse.cz> | ||
| 3 | Date: Mon, 7 Apr 2014 15:37:50 -0700 | ||
| 4 | Subject: [PATCH] mm: try_to_unmap_cluster() should lock_page() before mlocking | ||
| 5 | |||
| 6 | commit 57e68e9cd65b4b8eb4045a1e0d0746458502554c upstream. | ||
| 7 | |||
| 8 | A BUG_ON(!PageLocked) was triggered in mlock_vma_page() by Sasha Levin | ||
| 9 | fuzzing with trinity. The call site try_to_unmap_cluster() does not lock | ||
| 10 | the pages other than its check_page parameter (which is already locked). | ||
| 11 | |||
| 12 | The BUG_ON in mlock_vma_page() is not documented and its purpose is | ||
| 13 | somewhat unclear, but apparently it serializes against page migration, | ||
| 14 | which could otherwise fail to transfer the PG_mlocked flag. This would | ||
| 15 | not be fatal, as the page would be eventually encountered again, but | ||
| 16 | NR_MLOCK accounting would become distorted nevertheless. This patch adds | ||
| 17 | a comment to the BUG_ON in mlock_vma_page() and munlock_vma_page() to that | ||
| 18 | effect. | ||
| 19 | |||
| 20 | The call site try_to_unmap_cluster() is fixed so that for page != | ||
| 21 | check_page, trylock_page() is attempted (to avoid possible deadlocks as we | ||
| 22 | already have check_page locked) and mlock_vma_page() is performed only | ||
| 23 | upon success. If the page lock cannot be obtained, the page is left | ||
| 24 | without PG_mlocked, which is again not a problem in the whole unevictable | ||
| 25 | memory design. | ||
| 26 | |||
| 27 | Fixes CVE-2014-3122 | ||
| 28 | Upstream-Status: Backport | ||
| 29 | |||
| 30 | Signed-off-by: Vlastimil Babka <vbabka@suse.cz> | ||
| 31 | Signed-off-by: Bob Liu <bob.liu@oracle.com> | ||
| 32 | Reported-by: Sasha Levin <sasha.levin@oracle.com> | ||
| 33 | Cc: Wanpeng Li <liwanp@linux.vnet.ibm.com> | ||
| 34 | Cc: Michel Lespinasse <walken@google.com> | ||
| 35 | Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> | ||
| 36 | Acked-by: Rik van Riel <riel@redhat.com> | ||
| 37 | Cc: David Rientjes <rientjes@google.com> | ||
| 38 | Cc: Mel Gorman <mgorman@suse.de> | ||
| 39 | Cc: Hugh Dickins <hughd@google.com> | ||
| 40 | Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> | ||
| 41 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
| 42 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
| 43 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | ||
| 44 | Signed-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 | |||
| 50 | diff --git a/mm/mlock.c b/mm/mlock.c | ||
| 51 | index 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)) { | ||
| 70 | diff --git a/mm/rmap.c b/mm/rmap.c | ||
| 71 | index 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 | -- | ||
| 97 | 1.9.1 | ||
| 98 | |||
diff --git a/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb b/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb index a65c458de..7bf8b223c 100644 --- a/meta-fsl-ppc/recipes-kernel/linux/linux-qoriq_3.12.bb +++ b/meta-fsl-ppc/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 | " |
| 34 | SRCREV = "6619b8b55796cdf0cec04b66a71288edd3057229" | 35 | SRCREV = "6619b8b55796cdf0cec04b66a71288edd3057229" |
| 35 | 36 | ||
