Skip to content

Commit bfd3c70

Browse files
committed
mm/huge_memory: check pmd_special() only after pmd_present()
jira LE-3557 Rebuild_History Non-Buildable kernel-5.14.0-570.26.1.el9_6 commit-author David Hildenbrand <[email protected]> commit 47fa301 We should only check for pmd_special() after we made sure that we have a present PMD. For example, if we have a migration PMD, pmd_special() might indicate that we have a special PMD although we really don't. This fixes confusing migration entries as PFN mappings, and not doing what we are supposed to do in the "is_swap_pmd()" case further down in the function -- including messing up COW, page table handling and accounting. Link: https://lkml.kernel.org/r/[email protected] Fixes: bc02afb ("mm/fork: accept huge pfnmap entries") Signed-off-by: David Hildenbrand <[email protected]> Reported-by: [email protected] Closes: https://lore.kernel.org/lkml/[email protected]/ Reviewed-by: Peter Xu <[email protected]> Signed-off-by: Andrew Morton <[email protected]> (cherry picked from commit 47fa301) Signed-off-by: Jonathan Maple <[email protected]>
1 parent 0aae8b4 commit bfd3c70

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/huge_memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
10751075
int ret = -ENOMEM;
10761076

10771077
pmd = pmdp_get_lockless(src_pmd);
1078-
if (unlikely(pmd_special(pmd))) {
1078+
if (unlikely(pmd_present(pmd) && pmd_special(pmd))) {
10791079
dst_ptl = pmd_lock(dst_mm, dst_pmd);
10801080
src_ptl = pmd_lockptr(src_mm, src_pmd);
10811081
spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING);

0 commit comments

Comments
 (0)