From: Hugh Dickins <hughd@google.com>
To: Song Liu <song@kernel.org>
Cc: Matthew Wilcox <willy@infradead.org>,
Hugh Dickins <hughd@google.com>,
Song Liu <songliubraving@fb.com>, Jiri Olsa <jolsa@kernel.org>,
David Stevens <stevensd@chromium.org>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
Peter Xu <peterx@redhat.com>,
"Kirill A . Shutemov" <kirill@shutemov.name>,
Yang Shi <shy828301@gmail.com>,
David Hildenbrand <david@redhat.com>,
Jiaqi Yan <jiaqiyan@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/3] mm/khugepaged: maintain page cache uptodate flag
Date: Thu, 23 Mar 2023 18:56:34 -0700 (PDT) [thread overview]
Message-ID: <b49b118d-893c-c749-61f6-9441539418a5@google.com> (raw)
In-Reply-To: <CAPhsuW5pTh2+S7VjRbRy=WUAb7-GLQpi6HKCW0ehxs5HAup_dQ@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1553 bytes --]
On Thu, 23 Mar 2023, Song Liu wrote:
> On Thu, Mar 23, 2023 at 2:56 PM Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Thu, Mar 23, 2023 at 12:07:46PM -0700, Hugh Dickins wrote:
> > > On an earlier audit, for different reasons, I did also run across
> > > lib/buildid.c build_id_parse() using find_get_page() without checking
> > > PageUptodate() - looks as if it might do the wrong thing if it races
> > > with khugepaged collapsing text to huge, and should probably have a
> > > similar fix.
> >
> > That shouldn't be using find_get_page(). It should probably use
> > read_cache_folio() which will actually read in the data if it's not
> > present in the page cache, and return an ERR_PTR if the data couldn't
> > be read.
>
> build_id_parse() can be called from NMI, so I don't think we can let
> read_cache_folio() read-in the data.
Interesting.
This being the same Layering_Violation_ID which is asking for a home in
everyone's struct file? (Okay, I'm being disagreeable, no need to answer!)
I think even the current find_get_page() is unsafe from NMI: imagine that
NMI interrupting a sequence (maybe THP collapse or splitting, maybe page
migration, maybe others) when the page refcount has been frozen to 0:
you'll just have to reboot the machine?
I guess the RCU-safety of find_get_page() implies that its XArray basics
are safe in NMI; but you need a low-level variant (xas_find()?) which
does none of the "goto retry"s, and fails immediately if anything is
wrong - including !PageUptodate.
Hugh
next prev parent reply other threads:[~2023-03-24 1:56 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 5:20 [PATCH v5 0/3] mm/khugepaged: fix khugepaged+shmem races David Stevens
2023-03-07 5:20 ` [PATCH v5 1/3] mm/khugepaged: refactor collapse_file control flow David Stevens
2023-03-23 19:51 ` Hugh Dickins
2023-03-07 5:20 ` [PATCH v5 2/3] mm/khugepaged: skip shmem with userfaultfd David Stevens
2023-03-23 19:48 ` Hugh Dickins
2023-03-24 5:34 ` David Stevens
2023-03-28 15:48 ` Peter Xu
2023-03-07 5:20 ` [PATCH v5 3/3] mm/khugepaged: maintain page cache uptodate flag David Stevens
2023-03-23 19:07 ` Hugh Dickins
2023-03-23 21:56 ` Matthew Wilcox
2023-03-23 22:28 ` Song Liu
2023-03-24 1:56 ` Hugh Dickins [this message]
2023-03-24 3:30 ` Matthew Wilcox
2023-03-24 6:03 ` Song Liu
2023-03-24 13:31 ` Matthew Wilcox
2023-03-29 16:53 ` Song Liu
2023-03-28 9:48 ` 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=b49b118d-893c-c749-61f6-9441539418a5@google.com \
--to=hughd@google.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=jiaqiyan@google.com \
--cc=jolsa@kernel.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterx@redhat.com \
--cc=shy828301@gmail.com \
--cc=song@kernel.org \
--cc=songliubraving@fb.com \
--cc=stevensd@chromium.org \
--cc=willy@infradead.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