From: Matthew Wilcox <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Hugh Dickins <hughd@google.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] shmem: Update folio if shmem_replace_page() updates the page
Date: Wed, 3 Aug 2022 04:17:50 +0100 [thread overview]
Message-ID: <Yuno3hVxk+rOheVs@casper.infradead.org> (raw)
In-Reply-To: <20220802174637.3bd3478d137b52ef3b67c3b3@linux-foundation.org>
On Tue, Aug 02, 2022 at 05:46:37PM -0700, Andrew Morton wrote:
> On Sat, 30 Jul 2022 05:25:18 +0100 "Matthew Wilcox (Oracle)" <willy@infradead.org> wrote:
>
> > If we allocate a new page, we need to make sure that our folio matches
> > that new page. This will be solved by changing shmem_replace_page()
> > to shmem_replace_folio(), but this is the minimal fix.
> >
> > ...
> >
> > --- a/mm/shmem.c
> > +++ b/mm/shmem.c
> > @@ -1771,6 +1771,7 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
> >
> > if (shmem_should_replace_folio(folio, gfp)) {
> > error = shmem_replace_page(&page, gfp, info, index);
> > + folio = page_folio(page);
> > if (error)
> > goto failed;
> > }
>
> What are the user-visible runtime effects of the bug?
>
> Should we backport this into 5.19.X?
Definitely should be backported. The next line not visible in this
patch context says:
error = shmem_add_to_page_cache(folio, mapping, index,
swp_to_radix_entry(swap), gfp,
charge_mm);
so if we do end up in this path, we store the wrong page in the
shmem inode's page cache, and I would rather imagine that data
corruption ensues.
next prev parent reply other threads:[~2022-08-03 3:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-30 4:25 Matthew Wilcox (Oracle)
2022-08-03 0:46 ` Andrew Morton
2022-08-03 3:17 ` Matthew Wilcox [this message]
2022-08-05 20:34 ` William Kucharski
2022-08-05 20:52 ` William Kucharski
2022-08-10 16:03 ` Hugh Dickins
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=Yuno3hVxk+rOheVs@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.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