Skip to contentSkip to conversation

FAILED: patch "[PATCH] mm/hugetlb: avoid corrupting page->mapping in" failed to apply to 5.15-stable tree

PATCH [email protected] 3 participants 3 messages Aug 29, 2022 – Aug 30, 2022

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 5.15-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 <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ab74ef708dc51df7cf2b8a890b9c6990fac5c0c6 Mon Sep 17 00:00:00 2001
From: Miaohe Lin <[email protected]>
Date: Tue, 12 Jul 2022 21:05:42 +0800
Subject: [PATCH] mm/hugetlb: avoid corrupting page->mapping in
hugetlb_mcopy_atomic_pte

In MCOPY_ATOMIC_CONTINUE case with a non-shared VMA, pages in the page cache are installed in the ptes. But hugepage_add_new_anon_rmap is called for them mistakenly because they're not vm_shared. This will corrupt the page->mapping used by page cache code.

Fixes f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl")
Cc Axel Rasmussen <[email protected]>
Cc Peter Xu <[email protected]>
mm/hugetlb.c +1 -1
index 2480ba627aa5..e070b8593b37 100644
@@ -6041,7 +6041,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
 	if (!huge_pte_none_mostly(huge_ptep_get(dst_pte)))
 		goto out_release_unlock;
 
-	if (vm_shared) {
+	if (page_in_pagecache) {
 		page_dup_file_rmap(page, true);
 	} else {
 		ClearHPageRestoreReserve(page);
#1 lore raw
Quoted 6 lines · On Mon, Aug 29, 2022 at 12:38 AM <[email protected]> wrote:

The patch below does not apply to the 5.15-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 <[email protected]>.

I'm in favor of applying this to 5.15. I can send a backport, unless someone else was already planning to do it (don't want to duplicate effort)?

Quoted 41 lines

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ab74ef708dc51df7cf2b8a890b9c6990fac5c0c6 Mon Sep 17 00:00:00 2001
From: Miaohe Lin <[email protected]>
Date: Tue, 12 Jul 2022 21:05:42 +0800
Subject: [PATCH] mm/hugetlb: avoid corrupting page->mapping in
hugetlb_mcopy_atomic_pte

In MCOPY_ATOMIC_CONTINUE case with a non-shared VMA, pages in the page cache are installed in the ptes. But hugepage_add_new_anon_rmap is called for them mistakenly because they're not vm_shared. This will corrupt the page->mapping used by page cache code.

Fixes f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl")
Cc Axel Rasmussen <[email protected]>
Cc Peter Xu <[email protected]>
mm/hugetlb.c +1 -1
index 2480ba627aa5..e070b8593b37 100644
@@ -6041,7 +6041,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
        if (!huge_pte_none_mostly(huge_ptep_get(dst_pte)))
                goto out_release_unlock;
 
-       if (vm_shared) {
+       if (page_in_pagecache) {
                page_dup_file_rmap(page, true);
        } else {
                ClearHPageRestoreReserve(page);
#2 lore raw
Quoted 11 lines · Axel Rasmussen
Quoted 6 lines · On Mon, Aug 29, 2022 at 12:38 AM <[email protected]> wrote:

The patch below does not apply to the 5.15-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 <[email protected]>.

I'm in favor of applying this to 5.15. I can send a backport, unless someone else was already planning to do it (don't want to duplicate effort)?

That's very kind of you. Thanks for doing this.

Thanks,
Miaohe Lin

Quoted 44 lines
Quoted 34 lines

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From ab74ef708dc51df7cf2b8a890b9c6990fac5c0c6 Mon Sep 17 00:00:00 2001
From: Miaohe Lin <[email protected]>
Date: Tue, 12 Jul 2022 21:05:42 +0800
Subject: [PATCH] mm/hugetlb: avoid corrupting page->mapping in
hugetlb_mcopy_atomic_pte

In MCOPY_ATOMIC_CONTINUE case with a non-shared VMA, pages in the page cache are installed in the ptes. But hugepage_add_new_anon_rmap is called for them mistakenly because they're not vm_shared. This will corrupt the page->mapping used by page cache code.

Fixes f619147104c8 ("userfaultfd: add UFFDIO_CONTINUE ioctl")
Cc Axel Rasmussen <[email protected]>
Cc Peter Xu <[email protected]>
mm/hugetlb.c +0 -0
index 2480ba627aa5..e070b8593b37 100644

mm/hugetlb.c int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm, · line 6047

Quoted 8 lines
mm/hugetlb.c +1 -1
@@ -6041,7 +6041,7 @@ int hugetlb_mcopy_atomic_pte(struct mm_struct *dst_mm,
        if (!huge_pte_none_mostly(huge_ptep_get(dst_pte)))
                goto out_release_unlock;
 
-       if (vm_shared) {
+       if (page_in_pagecache) {
                page_dup_file_rmap(page, true);
        } else {
                ClearHPageRestoreReserve(page);

.