Skip to contentSkip to conversation

mm-gup-fix-follow_devmap_pd-on-page==null-handling.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Dec 11, 2023

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled

     Subject: mm/gup: fix follow_devmap_p[mu]d() on page==NULL handling
has been removed from the -mm tree.  Its filename was
     mm-gup-fix-follow_devmap_pd-on-page==null-handling.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Peter Xu <[email protected]>
Subject: mm/gup: fix follow_devmap_p[mu]d() on page==NULL handling
Date: Thu, 23 Nov 2023 13:02:22 -0500

This is a bug found not by any report but only by code observations.

When GUP sees a devpmd/devpud and if page==NULL is returned, it means a fault is probably required. Here falling through when page==NULL can cause unexpected behavior.

Fix both cases by catching the page==NULL cases with no_page_table().

Fixes 3565fce3a659 ("mm, x86: get_user_pages() for dax mappings")
Fixes 080dbb618b4b ("mm/follow_page_mask: split follow_page_mask to smaller functions.")
Cc Dan Williams <[email protected]>
Cc Mel Gorman <[email protected]>
Cc Matthew Wilcox <[email protected]>
Cc Aneesh Kumar K.V <[email protected]>
Cc Christoph Hellwig <[email protected]>

---

 mm/gup.c |    2 ++
 1 file changed, 2 insertions(+)
mm/gup.c renamed from mm/gup.c~mm-gup-fix-follow_devmap_pd-on-page==null-handling +2 -0
@@ -710,6 +710,7 @@ static struct page *follow_pmd_mask(stru
 		spin_unlock(ptl);
 		if (page)
 			return page;
+		return no_page_table(vma, flags);
 	}
 	if (likely(!pmd_trans_huge(pmdval)))
 		return follow_page_pte(vma, address, pmd, flags, &ctx->pgmap);
@@ -758,6 +759,7 @@ static struct page *follow_pud_mask(stru
 		spin_unlock(ptl);
 		if (page)
 			return page;
+		return no_page_table(vma, flags);
 	}
 	if (unlikely(pud_bad(*pud)))
 		return no_page_table(vma, flags);

_

Patches currently in -mm which might be from [email protected] are