* FAILED: patch "[PATCH] thp: use is_zero_pfn() only after pte_present() check" failed to apply to 4.2-stable tree
@ 2015-11-06 0:29 gregkh
2015-11-06 2:16 ` Minchan Kim
0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2015-11-06 0:29 UTC (permalink / raw)
To: minchan, aarcange, akpm, hughd, kirill.shutemov, mgorman, riel,
stable, torvalds, vbabka
Cc: stable
The patch below does not apply to the 4.2-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
>From 47aee4d8e314384807e98b67ade07f6da476aa75 Mon Sep 17 00:00:00 2001
From: Minchan Kim <minchan@kernel.org>
Date: Thu, 22 Oct 2015 13:32:19 -0700
Subject: [PATCH] thp: use is_zero_pfn() only after pte_present() check
Use is_zero_pfn() on pteval only after pte_present() check on pteval
(It might be better idea to introduce is_zero_pte() which checks
pte_present() first).
Otherwise when working on a swap or migration entry and if pte_pfn's
result is equal to zero_pfn by chance, we lose user's data in
__collapse_huge_page_copy(). So if you're unlucky, the application
segfaults and finally you could see below message on exit:
BUG: Bad rss-counter state mm:ffff88007f099300 idx:2 val:3
Fixes: ca0984caa823 ("mm: incorporate zero pages into transparent huge pages")
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Mel Gorman <mgorman@suse.de>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: <stable@vger.kernel.org> [4.1+]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 4b06b8db9df2..bbac913f96bc 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2206,7 +2206,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
for (_pte = pte; _pte < pte+HPAGE_PMD_NR;
_pte++, address += PAGE_SIZE) {
pte_t pteval = *_pte;
- if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) {
+ if (pte_none(pteval) || (pte_present(pteval) &&
+ is_zero_pfn(pte_pfn(pteval)))) {
if (!userfaultfd_armed(vma) &&
++none_or_zero <= khugepaged_max_ptes_none)
continue;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: FAILED: patch "[PATCH] thp: use is_zero_pfn() only after pte_present() check" failed to apply to 4.2-stable tree
2015-11-06 0:29 FAILED: patch "[PATCH] thp: use is_zero_pfn() only after pte_present() check" failed to apply to 4.2-stable tree gregkh
@ 2015-11-06 2:16 ` Minchan Kim
0 siblings, 0 replies; 2+ messages in thread
From: Minchan Kim @ 2015-11-06 2:16 UTC (permalink / raw)
To: gregkh
Cc: aarcange, akpm, hughd, kirill.shutemov, mgorman, riel, stable,
torvalds, vbabka
Hi Greg,
On Thu, Nov 05, 2015 at 04:29:48PM -0800, gregkh@linuxfoundation.org wrote:
>
> The patch below does not apply to the 4.2-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.
This is backport patch for v4.2.5.
If something is wrong(e.g. process, description and so on),
let me know it.
Thanks.
>From 6db5ccd1e927fc1181ea849ca73f089608071ed9 Mon Sep 17 00:00:00 2001
From: Minchan Kim <minchan@kernel.org>
Date: Fri, 6 Nov 2015 11:11:08 +0900
Subject: [PATCH] thp: use is_zero_pfn() only after pte_present() check
This is backport for v4.2.5
Original commit id is 47aee4d8e314384807e98b67ade07f6da476aa75
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
mm/huge_memory.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 097c7a4..da0ac6a 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2132,7 +2132,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
for (_pte = pte; _pte < pte+HPAGE_PMD_NR;
_pte++, address += PAGE_SIZE) {
pte_t pteval = *_pte;
- if (pte_none(pteval) || is_zero_pfn(pte_pfn(pteval))) {
+ if (pte_none(pteval) || (pte_present(pteval) &&
+ is_zero_pfn(pte_pfn(pteval)))) {
if (++none_or_zero <= khugepaged_max_ptes_none)
continue;
else
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-06 2:15 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-06 0:29 FAILED: patch "[PATCH] thp: use is_zero_pfn() only after pte_present() check" failed to apply to 4.2-stable tree gregkh
2015-11-06 2:16 ` Minchan Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).