linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Kravetz <mike.kravetz@oracle.com>
To: Peter Xu <peterx@redhat.com>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Mike Rapoport <rppt@linux.vnet.ibm.com>
Subject: Re: [PATCH] userfaultfd/hugetlbfs: Fix minor fault page leak
Date: Mon, 22 Mar 2021 13:13:15 -0700	[thread overview]
Message-ID: <816f4e98-6285-0a75-366a-c1025ab0c7f4@oracle.com> (raw)
In-Reply-To: <20210322175132.36659-1-peterx@redhat.com>

On 3/22/21 10:51 AM, Peter Xu wrote:
> When uffd-minor enabled, we need to put the page cache before handling the
> userfault in hugetlb_no_page(), otherwise the page refcount got leaked.
> 
> This can be reproduced by running userfaultfd selftest with hugetlb_shared
> mode, then cat /proc/meminfo.
> 
> Cc: Axel Rasmussen <axelrasmussen@google.com>
> Cc: Andrea Arcangeli <aarcange@redhat.com>
> Cc: Mike Kravetz <mike.kravetz@oracle.com>
> Cc: Mike Rapoport <rppt@linux.vnet.ibm.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Fixes: f2bf15fb0969 ("userfaultfd: add minor fault registration mode")
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  mm/hugetlb.c | 1 +
>  1 file changed, 1 insertion(+)

Thanks for finding/fixing.

Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>

I think this is just in Andrew's tree.  So it will need to be fixed
there.
-- 
Mike Kravetz

> 
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 408dbc08298a..56b78a206913 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -4449,6 +4449,7 @@ static vm_fault_t hugetlb_no_page(struct mm_struct *mm,
>  		/* Check for page in userfault range. */
>  		if (userfaultfd_minor(vma)) {
>  			unlock_page(page);
> +			put_page(page);
>  			ret = hugetlb_handle_userfault(vma, mapping, idx,
>  						       flags, haddr,
>  						       VM_UFFD_MINOR);
> 

  reply	other threads:[~2021-03-22 20:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-22 17:51 [PATCH] userfaultfd/hugetlbfs: Fix minor fault page leak Peter Xu
2021-03-22 20:13 ` Mike Kravetz [this message]
2021-03-22 20:19 ` Axel Rasmussen

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=816f4e98-6285-0a75-366a-c1025ab0c7f4@oracle.com \
    --to=mike.kravetz@oracle.com \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=peterx@redhat.com \
    --cc=rppt@linux.vnet.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).