public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
From: Hugh Dickins <hughd@google.com>
To: gregkh@linuxfoundation.org
Cc: aarcange@redhat.com, akpm@linux-foundation.org, hughd@google.com,
	kirill.shutemov@linux.intel.com, mike.kravetz@oracle.com,
	songliubraving@fb.com, torvalds@linux-foundation.org,
	stable-commits@vger.kernel.org, stable@vger.kernel.org
Subject: Re: Patch "khugepaged: khugepaged_test_exit() check mmget_still_valid()" has been added to the 5.8-stable tree
Date: Wed, 19 Aug 2020 06:32:26 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LSU.2.11.2008190625060.24442@eggly.anvils> (raw)
In-Reply-To: <1597841669128213@kroah.com>

On Wed, 19 Aug 2020, gregkh@linuxfoundation.org wrote:
> 
> This is a note to let you know that I've just added the patch titled
> 
>     khugepaged: khugepaged_test_exit() check mmget_still_valid()
> 
> to the 5.8-stable tree which can be found at:
>     http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
> 
> The filename of the patch is:
>      khugepaged-khugepaged_test_exit-check-mmget_still_valid.patch
> and it can be found in the queue-5.8 subdirectory.
> 
> If you, or anyone else, feels it should not be added to the stable tree,
> please let <stable@vger.kernel.org> know about it.

Please hold this one back for the moment: we shall want it, but syzbot
detected one place where it can lead to a VM_BUG_ON_MM().  The fix to
that is currently in Andrew's tree, but not yet in Linus's - when it
gets there, I'll send you its git commit id in reply to this mail.

This patch failed to apply to earlier releases: I'll send the fixup for
those at that time.  (Fixups for another patch to follow later today.)

Thanks,
Hugh

> 
> 
> From bbe98f9cadff58cdd6a4acaeba0efa8565dabe65 Mon Sep 17 00:00:00 2001
> From: Hugh Dickins <hughd@google.com>
> Date: Thu, 6 Aug 2020 23:26:25 -0700
> Subject: khugepaged: khugepaged_test_exit() check mmget_still_valid()
> 
> From: Hugh Dickins <hughd@google.com>
> 
> commit bbe98f9cadff58cdd6a4acaeba0efa8565dabe65 upstream.
> 
> Move collapse_huge_page()'s mmget_still_valid() check into
> khugepaged_test_exit() itself.  collapse_huge_page() is used for anon THP
> only, and earned its mmget_still_valid() check because it inserts a huge
> pmd entry in place of the page table's pmd entry; whereas
> collapse_file()'s retract_page_tables() or collapse_pte_mapped_thp()
> merely clears the page table's pmd entry.  But core dumping without mmap
> lock must have been as open to mistaking a racily cleared pmd entry for a
> page table at physical page 0, as exit_mmap() was.  And we certainly have
> no interest in mapping as a THP once dumping core.
> 
> Fixes: 59ea6d06cfa9 ("coredump: fix race condition between collapse_huge_page() and core dumping")
> Signed-off-by: Hugh Dickins <hughd@google.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Song Liu <songliubraving@fb.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> Cc: <stable@vger.kernel.org>	[4.8+]
> Link: http://lkml.kernel.org/r/alpine.LSU.2.11.2008021217020.27773@eggly.anvils
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> 
> ---
>  mm/khugepaged.c |    5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> --- a/mm/khugepaged.c
> +++ b/mm/khugepaged.c
> @@ -431,7 +431,7 @@ static void insert_to_mm_slots_hash(stru
>  
>  static inline int khugepaged_test_exit(struct mm_struct *mm)
>  {
> -	return atomic_read(&mm->mm_users) == 0;
> +	return atomic_read(&mm->mm_users) == 0 || !mmget_still_valid(mm);
>  }
>  
>  static bool hugepage_vma_check(struct vm_area_struct *vma,
> @@ -1100,9 +1100,6 @@ static void collapse_huge_page(struct mm
>  	 * handled by the anon_vma lock + PG_lock.
>  	 */
>  	mmap_write_lock(mm);
> -	result = SCAN_ANY_PROCESS;
> -	if (!mmget_still_valid(mm))
> -		goto out;
>  	result = hugepage_vma_revalidate(mm, address, &vma);
>  	if (result)
>  		goto out;
> 
> 
> Patches currently in stable-queue which might be from hughd@google.com are
> 
> queue-5.8/khugepaged-collapse_pte_mapped_thp-flush-the-right-range.patch
> queue-5.8/hugetlbfs-remove-call-to-huge_pte_alloc-without-i_mmap_rwsem.patch
> queue-5.8/khugepaged-khugepaged_test_exit-check-mmget_still_valid.patch
> queue-5.8/khugepaged-retract_page_tables-remember-to-test-exit.patch
> queue-5.8/khugepaged-collapse_pte_mapped_thp-protect-the-pmd-lock.patch
> 

       reply	other threads:[~2020-08-19 13:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1597841669128213@kroah.com>
2020-08-19 13:32 ` Hugh Dickins [this message]
2020-08-19 13:53   ` Patch "khugepaged: khugepaged_test_exit() check mmget_still_valid()" has been added to the 5.8-stable tree Greg KH
2020-08-22  1:26     ` Hugh Dickins
2020-08-22 21:20       ` Sasha Levin
2020-08-23  2:16         ` Hugh Dickins
2020-08-24 15:12           ` Hugh Dickins
2020-08-26 18:53             ` Hugh Dickins
2020-08-26 21:46               ` Sasha Levin
2020-08-26 21:54                 ` Hugh Dickins
2020-08-24 15:29           ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.2008190625060.24442@eggly.anvils \
    --to=hughd@google.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=mike.kravetz@oracle.com \
    --cc=songliubraving@fb.com \
    --cc=stable-commits@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox