From: Mike Kravetz <mike.kravetz@oracle.com>
To: Mina Almasry <almasrymina@google.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Wei Xu <weixugc@google.com>,
stable@vger.kernel.org, James Houghton <jthoughton@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] hugetlb, userfaultfd: Fix reservation restore on userfaultfd error
Date: Wed, 17 Nov 2021 12:44:12 -0800 [thread overview]
Message-ID: <a51f7e4c-674d-a282-e3dd-c03a199ef5d6@oracle.com> (raw)
In-Reply-To: <20211117193825.378528-1-almasrymina@google.com>
On 11/17/21 11:38, Mina Almasry wrote:
> Currently in the is_continue case in hugetlb_mcopy_atomic_pte(), if we
> bail out using "goto out_release_unlock;" in the cases where idx >=
> size, or !huge_pte_none(), the code will detect that new_pagecache_page
> == false, and so call restore_reserve_on_error().
> In this case I see restore_reserve_on_error() delete the reservation,
> and the following call to remove_inode_hugepages() will increment
> h->resv_hugepages causing a 100% reproducible leak.
>
> We should treat the is_continue case similar to adding a page into the
> pagecache and set new_pagecache_page to true, to indicate that there is
> no reservation to restore on the error path, and we need not call
> restore_reserve_on_error(). Rename new_pagecache_page to
> page_in_pagecache to make that clear.
>
> Cc: Wei Xu <weixugc@google.com>
>
> Cc: stable@vger.kernel.org
>
> Fixes: c7b1850dfb41 ("hugetlb: don't pass page cache pages to restore_reserve_on_error")
> Signed-off-by: Mina Almasry <almasrymina@google.com>
> Reported-by: James Houghton <jthoughton@google.com>
>
>
> ---
>
> Changes in v2:
> - Renamed new_pagecache_page to page_in_pagecache
> - Removed unnecessary comment after the name update.
> - Cc: stable
Thanks for making the changes!
Reviewed-by: Mike Kravetz <mike.kravetz@oracle.com>
--
Mike Kravetz
prev parent reply other threads:[~2021-11-17 20:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-17 19:38 [PATCH v2] hugetlb, userfaultfd: Fix reservation restore on userfaultfd error Mina Almasry
2021-11-17 20:44 ` Mike Kravetz [this message]
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=a51f7e4c-674d-a282-e3dd-c03a199ef5d6@oracle.com \
--to=mike.kravetz@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=almasrymina@google.com \
--cc=jthoughton@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
--cc=weixugc@google.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).