mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
thp: use is_zero_pfn() only after pte_present() check
commit47aee4d8e3upstream. 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:ca0984caa8("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> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
435d5d7f3a
commit
dc14f050d2
@@ -2137,7 +2137,8 @@ static int __collapse_huge_page_isolate(struct vm_area_struct *vma,
|
|||||||
for (_pte = pte; _pte < pte+HPAGE_PMD_NR;
|
for (_pte = pte; _pte < pte+HPAGE_PMD_NR;
|
||||||
_pte++, address += PAGE_SIZE) {
|
_pte++, address += PAGE_SIZE) {
|
||||||
pte_t pteval = *_pte;
|
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)
|
if (++none_or_zero <= khugepaged_max_ptes_none)
|
||||||
continue;
|
continue;
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user