From: Matthew Wilcox <willy@infradead.org>
To: Jeongjun Park <aha310510@gmail.com>
Cc: David Hildenbrand <david@redhat.com>,
akpm@linux-foundation.org, wangkefeng.wang@huawei.com,
ziy@nvidia.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, syzbot <syzkaller@googlegroups.com>
Subject: Re: [PATCH] mm: migrate: fix data-race in migrate_folio_unmap()
Date: Tue, 24 Sep 2024 03:26:13 +0100 [thread overview]
Message-ID: <ZvIjRZgyAGLmys7c@casper.infradead.org> (raw)
In-Reply-To: <B1FCFC88-1242-4472-BCED-71BA9530B639@gmail.com>
On Tue, Sep 24, 2024 at 09:28:44AM +0900, Jeongjun Park wrote:
> > Matthew Wilcox <willy@infradead.org> wrote:
> >
> > On Mon, Sep 23, 2024 at 05:56:40PM +0200, David Hildenbrand wrote:
> >>> On 22.09.24 17:17, Jeongjun Park wrote:
> >>> I found a report from syzbot [1]
> >>>
> >>> When __folio_test_movable() is called in migrate_folio_unmap() to read
> >>> folio->mapping, a data race occurs because the folio is read without
> >>> protecting it with folio_lock.
> >>>
> >>> This can cause unintended behavior because folio->mapping is initialized
> >>> to a NULL value. Therefore, I think it is appropriate to call
> >>> __folio_test_movable() under the protection of folio_lock to prevent
> >>> data-race.
> >>
> >> We hold a folio reference, would we really see PAGE_MAPPING_MOVABLE flip?
> >> Hmm
> >
> > No; this shows a page cache folio getting truncated. It's fine; really
> > a false alarm from the tool. I don't think the proposed patch
> > introduces any problems, but it's all a bit meh.
> >
>
> Well, I still don't understand why it's okay to read folio->mapping
> without folio_lock .
Because it can't be changed in a way which changes the value of
__folio_test_movable(). We have a refcount on the folio at this point,
so it can't be freed. And __folio_set_movable() happens at allocation.
next prev parent reply other threads:[~2024-09-24 2:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-22 15:17 Jeongjun Park
2024-09-23 15:56 ` David Hildenbrand
2024-09-23 19:57 ` Matthew Wilcox
2024-09-24 0:28 ` Jeongjun Park
2024-09-24 2:26 ` Matthew Wilcox [this message]
2024-09-24 4:49 ` Jeongjun Park
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=ZvIjRZgyAGLmys7c@casper.infradead.org \
--to=willy@infradead.org \
--cc=aha310510@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=stable@vger.kernel.org \
--cc=syzkaller@googlegroups.com \
--cc=wangkefeng.wang@huawei.com \
--cc=ziy@nvidia.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