Re: [PATCH] mm: migrate: fix data-race in migrate_folio_unmap()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 24, 2024 at 09:28:44AM +0900, Jeongjun Park wrote:
> > Matthew Wilcox <willy@xxxxxxxxxxxxx> 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.





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux