All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] mm/hugetlb: separate path for hwpoison entry in" failed to apply to 5.18-stable tree
@ 2022-07-30 15:35 gregkh
  2022-08-01  6:29 ` Naoya Horiguchi
  0 siblings, 1 reply; 4+ messages in thread
From: gregkh @ 2022-07-30 15:35 UTC (permalink / raw)
  To: naoya.horiguchi, akpm, david, linmiaohe, liushixin2,
	mike.kravetz, osalvador, shy828301, songmuchun, stable
  Cc: stable


The patch below does not apply to the 5.18-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 c2cb0dcce9dd8b748b6ca8bb8d4a389f2e232307 Mon Sep 17 00:00:00 2001
From: Naoya Horiguchi <naoya.horiguchi@nec.com>
Date: Mon, 4 Jul 2022 10:33:05 +0900
Subject: [PATCH] mm/hugetlb: separate path for hwpoison entry in
 copy_hugetlb_page_range()

Originally copy_hugetlb_page_range() handles migration entries and
hwpoisoned entries in similar manner.  But recently the related code path
has more code for migration entries, and when
is_writable_migration_entry() was converted to
!is_readable_migration_entry(), hwpoison entries on source processes got
to be unexpectedly updated (which is legitimate for migration entries, but
not for hwpoison entries).  This results in unexpected serious issues like
kernel panic when forking processes with hwpoison entries in pmd.

Separate the if branch into one for hwpoison entries and one for migration
entries.

Link: https://lkml.kernel.org/r/20220704013312.2415700-3-naoya.horiguchi@linux.dev
Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive")
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: <stable@vger.kernel.org>	[5.18]
Cc: David Hildenbrand <david@redhat.com>
Cc: Liu Shixin <liushixin2@huawei.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Yang Shi <shy828301@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index a57e1be41401..baf7f6b19ce6 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4788,8 +4788,13 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
 			 * sharing with another vma.
 			 */
 			;
-		} else if (unlikely(is_hugetlb_entry_migration(entry) ||
-				    is_hugetlb_entry_hwpoisoned(entry))) {
+		} else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) {
+			bool uffd_wp = huge_pte_uffd_wp(entry);
+
+			if (!userfaultfd_wp(dst_vma) && uffd_wp)
+				entry = huge_pte_clear_uffd_wp(entry);
+			set_huge_pte_at(dst, addr, dst_pte, entry);
+		} else if (unlikely(is_hugetlb_entry_migration(entry))) {
 			swp_entry_t swp_entry = pte_to_swp_entry(entry);
 			bool uffd_wp = huge_pte_uffd_wp(entry);
 


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] mm/hugetlb: separate path for hwpoison entry in" failed to apply to 5.18-stable tree
  2022-07-30 15:35 FAILED: patch "[PATCH] mm/hugetlb: separate path for hwpoison entry in" failed to apply to 5.18-stable tree gregkh
@ 2022-08-01  6:29 ` Naoya Horiguchi
  2022-08-01  8:19   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Naoya Horiguchi @ 2022-08-01  6:29 UTC (permalink / raw)
  To: gregkh, stable
  Cc: akpm, david, linmiaohe, liushixin2, mike.kravetz, osalvador,
	shy828301, songmuchun, naoya.horiguchi, naoya.horiguchi

On Sat, Jul 30, 2022 at 05:35:37PM +0200, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 5.18-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,

Hello,

I updated the patch for 5.18-stable, could you apply this?

Thanks,
Naoya Horiguchi
---
From: Naoya Horiguchi <naoya.horiguchi@nec.com>
Date: Mon, 1 Aug 2022 15:09:17 +0900
Subject: [PATCH] mm/hugetlb: separate path for hwpoison entry in
 copy_hugetlb_page_range()

commit c2cb0dcce9dd8b748b6ca8bb8d4a389f2e232307 upstream.

Originally copy_hugetlb_page_range() handles migration entries and
hwpoisoned entries in similar manner.  But recently the related code path
has more code for migration entries, and when
is_writable_migration_entry() was converted to
!is_readable_migration_entry(), hwpoison entries on source processes got
to be unexpectedly updated (which is legitimate for migration entries, but
not for hwpoison entries).  This results in unexpected serious issues like
kernel panic when forking processes with hwpoison entries in pmd.

Separate the if branch into one for hwpoison entries and one for migration
entries.

[naoya.horiguchi: Resolved conflict to apply for 5.18-stable.]

Link: https://lkml.kernel.org/r/20220704013312.2415700-3-naoya.horiguchi@linux.dev
Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive")
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Cc: <stable@vger.kernel.org>	[5.18]
Cc: David Hildenbrand <david@redhat.com>
Cc: Liu Shixin <liushixin2@huawei.com>
Cc: Oscar Salvador <osalvador@suse.de>
Cc: Yang Shi <shy828301@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
 mm/hugetlb.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 410bbb0aee32..0aa670addd8c 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4764,8 +4764,9 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
 			 * sharing with another vma.
 			 */
 			;
-		} else if (unlikely(is_hugetlb_entry_migration(entry) ||
-				    is_hugetlb_entry_hwpoisoned(entry))) {
+		} else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) {
+			set_huge_pte_at(dst, addr, dst_pte, entry);
+		} else if (unlikely(is_hugetlb_entry_migration(entry))) {
 			swp_entry_t swp_entry = pte_to_swp_entry(entry);
 
 			if (is_writable_migration_entry(swp_entry) && cow) {
-- 
2.26.1.8815.g6a475b71f8



> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
> From c2cb0dcce9dd8b748b6ca8bb8d4a389f2e232307 Mon Sep 17 00:00:00 2001
> From: Naoya Horiguchi <naoya.horiguchi@nec.com>
> Date: Mon, 4 Jul 2022 10:33:05 +0900
> Subject: [PATCH] mm/hugetlb: separate path for hwpoison entry in
>  copy_hugetlb_page_range()
> 
> Originally copy_hugetlb_page_range() handles migration entries and
> hwpoisoned entries in similar manner.  But recently the related code path
> has more code for migration entries, and when
> is_writable_migration_entry() was converted to
> !is_readable_migration_entry(), hwpoison entries on source processes got
> to be unexpectedly updated (which is legitimate for migration entries, but
> not for hwpoison entries).  This results in unexpected serious issues like
> kernel panic when forking processes with hwpoison entries in pmd.
> 
> Separate the if branch into one for hwpoison entries and one for migration
> entries.
> 
> Link: https://lkml.kernel.org/r/20220704013312.2415700-3-naoya.horiguchi@linux.dev
> Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive")
> Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
> Reviewed-by: Miaohe Lin <linmiaohe@huawei.com>
> Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
> Reviewed-by: Muchun Song <songmuchun@bytedance.com>
> Cc: <stable@vger.kernel.org>	[5.18]
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Liu Shixin <liushixin2@huawei.com>
> Cc: Oscar Salvador <osalvador@suse.de>
> Cc: Yang Shi <shy828301@gmail.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index a57e1be41401..baf7f6b19ce6 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4788,8 +4788,13 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,
>  			 * sharing with another vma.
>  			 */
>  			;
> -		} else if (unlikely(is_hugetlb_entry_migration(entry) ||
> -				    is_hugetlb_entry_hwpoisoned(entry))) {
> +		} else if (unlikely(is_hugetlb_entry_hwpoisoned(entry))) {
> +			bool uffd_wp = huge_pte_uffd_wp(entry);
> +
> +			if (!userfaultfd_wp(dst_vma) && uffd_wp)
> +				entry = huge_pte_clear_uffd_wp(entry);
> +			set_huge_pte_at(dst, addr, dst_pte, entry);
> +		} else if (unlikely(is_hugetlb_entry_migration(entry))) {
>  			swp_entry_t swp_entry = pte_to_swp_entry(entry);
>  			bool uffd_wp = huge_pte_uffd_wp(entry);
>  

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] mm/hugetlb: separate path for hwpoison entry in" failed to apply to 5.18-stable tree
  2022-08-01  6:29 ` Naoya Horiguchi
@ 2022-08-01  8:19   ` Greg KH
  2022-08-01  8:32     ` HORIGUCHI NAOYA(堀口 直也)
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2022-08-01  8:19 UTC (permalink / raw)
  To: Naoya Horiguchi
  Cc: stable, akpm, david, linmiaohe, liushixin2, mike.kravetz,
	osalvador, shy828301, songmuchun, naoya.horiguchi

On Mon, Aug 01, 2022 at 03:29:37PM +0900, Naoya Horiguchi wrote:
> On Sat, Jul 30, 2022 at 05:35:37PM +0200, gregkh@linuxfoundation.org wrote:
> > 
> > The patch below does not apply to the 5.18-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,
> 
> Hello,
> 
> I updated the patch for 5.18-stable, could you apply this?

I can, but are you sure you need/want this for 5.18-stable?

I ask because of this line in the changelog text:

> Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive")

Which only showed up in 5.19-rc1 and is not backported anywhere.

So why did you have:

> Cc: <stable@vger.kernel.org>	[5.18]

In the changelog if the commit this fixes is not in 5.18?

confused,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: FAILED: patch "[PATCH] mm/hugetlb: separate path for hwpoison entry in" failed to apply to 5.18-stable tree
  2022-08-01  8:19   ` Greg KH
@ 2022-08-01  8:32     ` HORIGUCHI NAOYA(堀口 直也)
  0 siblings, 0 replies; 4+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2022-08-01  8:32 UTC (permalink / raw)
  To: Greg KH
  Cc: Naoya Horiguchi, stable, akpm, david, linmiaohe, liushixin2,
	mike.kravetz, osalvador, shy828301, songmuchun

On Mon, Aug 01, 2022 at 10:19:05AM +0200, Greg KH wrote:
> On Mon, Aug 01, 2022 at 03:29:37PM +0900, Naoya Horiguchi wrote:
> > On Sat, Jul 30, 2022 at 05:35:37PM +0200, gregkh@linuxfoundation.org wrote:
> > > 
> > > The patch below does not apply to the 5.18-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,
> > 
> > Hello,
> > 
> > I updated the patch for 5.18-stable, could you apply this?
> 
> I can, but are you sure you need/want this for 5.18-stable?
> 
> I ask because of this line in the changelog text:
> 
> > Fixes: 6c287605fd56 ("mm: remember exclusively mapped anonymous pages with PG_anon_exclusive")
> 
> Which only showed up in 5.19-rc1 and is not backported anywhere.

OK, So we don't have to backport this patch.

> 
> So why did you have:
> 
> > Cc: <stable@vger.kernel.org>	[5.18]
> 
> In the changelog if the commit this fixes is not in 5.18?

I wrongly judged that 6c287605fd56 was before 5.19, sorry about that.
Please ignore my backport request.

Thanks,
Naoya Horiguchi

> 
> confused,
> 
> greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-08-01  8:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-30 15:35 FAILED: patch "[PATCH] mm/hugetlb: separate path for hwpoison entry in" failed to apply to 5.18-stable tree gregkh
2022-08-01  6:29 ` Naoya Horiguchi
2022-08-01  8:19   ` Greg KH
2022-08-01  8:32     ` HORIGUCHI NAOYA(堀口 直也)

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.