Home Home > GIT Browse > SLE12-SP4
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlastimil Babka <vbabka@suse.cz>2019-01-14 10:07:57 +0100
committerVlastimil Babka <vbabka@suse.cz>2019-01-14 10:08:58 +0100
commit2b8ff432714af9ec566f169109853deeabaa0193 (patch)
tree5103dcfa4ae57c4999a51e3ccf45c5e78b916a61
parentc33ca328a24f5fc16c2427c491c18944e66e7b1a (diff)
mm/khugepaged: collapse_shmem() do not crash on Compound
(VM Functionality, bsc#1121599).
-rw-r--r--patches.fixes/mm-khugepaged-collapse_shmem-do-not-crash-on-compound.patch48
-rw-r--r--series.conf1
2 files changed, 49 insertions, 0 deletions
diff --git a/patches.fixes/mm-khugepaged-collapse_shmem-do-not-crash-on-compound.patch b/patches.fixes/mm-khugepaged-collapse_shmem-do-not-crash-on-compound.patch
new file mode 100644
index 0000000000..58d8996e22
--- /dev/null
+++ b/patches.fixes/mm-khugepaged-collapse_shmem-do-not-crash-on-compound.patch
@@ -0,0 +1,48 @@
+From: Hugh Dickins <hughd@google.com>
+Date: Fri, 30 Nov 2018 14:10:47 -0800
+Subject: mm/khugepaged: collapse_shmem() do not crash on Compound
+Git-commit: 06a5e1268a5fb9c2b346a3da6b97e85f2eba0f07
+Patch-mainline: v4.20-rc5
+References: VM Functionality, bsc#1121599
+
+collapse_shmem()'s VM_BUG_ON_PAGE(PageTransCompound) was unsafe: before
+it holds page lock of the first page, racing truncation then extension
+might conceivably have inserted a hugepage there already. Fail with the
+SCAN_PAGE_COMPOUND result, instead of crashing (CONFIG_DEBUG_VM=y) or
+otherwise mishandling the unexpected hugepage - though later we might
+code up a more constructive way of handling it, with SCAN_SUCCESS.
+
+Link: http://lkml.kernel.org/r/alpine.LSU.2.11.1811261529310.2275@eggly.anvils
+Fixes: f3f0e1d2150b2 ("khugepaged: add support of collapse for tmpfs/shmem pages")
+Signed-off-by: Hugh Dickins <hughd@google.com>
+Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
+Cc: Jerome Glisse <jglisse@redhat.com>
+Cc: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
+Cc: Matthew Wilcox <willy@infradead.org>
+Cc: <stable@vger.kernel.org> [4.8+]
+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/khugepaged.c | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+--- a/mm/khugepaged.c
++++ b/mm/khugepaged.c
+@@ -1396,7 +1396,15 @@ static void collapse_shmem(struct mm_str
+ */
+ VM_BUG_ON_PAGE(!PageLocked(page), page);
+ VM_BUG_ON_PAGE(!PageUptodate(page), page);
+- VM_BUG_ON_PAGE(PageTransCompound(page), page);
++
++ /*
++ * If file was truncated then extended, or hole-punched, before
++ * we locked the first page, then a THP might be there already.
++ */
++ if (PageTransCompound(page)) {
++ result = SCAN_PAGE_COMPOUND;
++ goto out_unlock;
++ }
+
+ if (page_mapping(page) != mapping) {
+ result = SCAN_TRUNCATED;
diff --git a/series.conf b/series.conf
index 6e18fd5932..b820d26221 100644
--- a/series.conf
+++ b/series.conf
@@ -19371,6 +19371,7 @@
patches.fixes/mm-khugepaged-collapse_shmem-remember-to-clear-holes.patch
patches.fixes/mm-khugepaged-minor-reorderings-in-collapse_shmem.patch
patches.fixes/mm-khugepaged-collapse_shmem-without-freezing-new_page.patch
+ patches.fixes/mm-khugepaged-collapse_shmem-do-not-crash-on-compound.patch
patches.drivers/pci-imx6-fix-link-training-status-detection-in-link-up-check
patches.fixes/fs-fix-lost-error-code-in-dio_complete.patch
patches.fixes/nvme-free-ctrl-device-name-on-init-failure.patch