linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: David Stevens <stevensd@chromium.org>
Cc: linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/khugepaged: skip shmem with armed userfaultfd
Date: Thu, 2 Feb 2023 02:09:43 +0300	[thread overview]
Message-ID: <20230201230943.fg2q6fmvu7gggxar@box.shutemov.name> (raw)
In-Reply-To: <20230201034137.2463113-1-stevensd@google.com>

On Wed, Feb 01, 2023 at 12:41:37PM +0900, David Stevens wrote:
> From: David Stevens <stevensd@chromium.org>
> 
> Collapsing memory in a vma that has an armed userfaultfd results in
> zero-filling any missing pages, which breaks user-space paging for those
> filled pages. Avoid khugepage bypassing userfaultfd by not collapsing
> pages in shmem reached via scanning a vma with an armed userfaultfd if
> doing so would zero-fill any pages.

Could you elaborate on the failure? Will zero-filling the page prevent
userfaultfd from catching future access?

A test-case would help a lot.

And what prevents the same pages be filled (with zeros or otherwise) via
write(2) bypassing VMA checks? I cannot immediately see it.

BTW, there's already a check that prevent establishing PMD in the place if
VM_UFFD_WP is set.

Maybe just an update of the check in retract_page_tables() from
userfaultfd_wp() to userfaultfd_armed() would be enough?

I have very limited understanding of userfaultfd(). Sorry in advance for
stupid questions.

-- 
  Kiryl Shutsemau / Kirill A. Shutemov

  parent reply	other threads:[~2023-02-01 23:09 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-01  3:41 [PATCH] mm/khugepaged: skip shmem with armed userfaultfd David Stevens
2023-02-01 17:36 ` Yang Shi
2023-02-01 20:52   ` Peter Xu
2023-02-01 23:57     ` Yang Shi
2023-02-02 20:04       ` Peter Xu
2023-02-02 21:11         ` Yang Shi
2023-02-02  9:56     ` David Stevens
2023-02-02 17:40       ` Yang Shi
2023-02-02 20:22         ` Peter Xu
2023-02-03  6:09           ` David Stevens
2023-02-03 14:56             ` Peter Xu
2023-02-01 23:09 ` Kirill A. Shutemov [this message]
2023-02-02  9:30   ` David Stevens

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=20230201230943.fg2q6fmvu7gggxar@box.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=stevensd@chromium.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;
as well as URLs for NNTP newsgroup(s).