Re: 6.6.8 stable: crash in folio_mark_dirty

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

 



On Mon, 1 Jan 2024 09:07:52 +0000 Matthew Wilcox
> On Mon, Jan 01, 2024 at 09:55:04AM +0800, Hillf Danton wrote:
> > On Sun, 31 Dec 2023 13:07:03 +0000 Matthew Wilcox <willy@xxxxxxxxxxxxx>
> > > I don't think this can happen.  Look at the call trace;
> > > block_dirty_folio() is called from unmap_page_range().  That means the
> > > page is in the page tables.  We unmap the pages in a folio from the
> > > page tables before we set folio->mapping to NULL.  Look at
> > > invalidate_inode_pages2_range() for example:
> > > 
> > >                                 unmap_mapping_pages(mapping, indices[i],
> > >                                                 (1 + end - indices[i]), false);
> > >                         folio_lock(folio);
> > >                         folio_wait_writeback(folio);
> > >                         if (folio_mapped(folio))
> > >                                 unmap_mapping_folio(folio);
> > >                         BUG_ON(folio_mapped(folio));
> > >                                 if (!invalidate_complete_folio2(mapping, folio))
> > > 
> > What is missed here is the same check [1] in invalidate_inode_pages2_range(),
> > so I built no wheel.
> > 
> > 			folio_lock(folio);
> > 			if (unlikely(folio->mapping != mapping)) {
> > 				folio_unlock(folio);
> > 				continue;
> > 			}
> > 
> > [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/mm/truncate.c#n658
> 
> That's entirely different.  That's checking in the truncate path whether
> somebody else already truncated this page.  What I was showing was why
> a page found through a page table walk cannot have been truncated (which
> is actually quite interesting, because it's the page table lock that
> prevents the race).
> 
Feel free to shed light on how ptl protects folio->mapping.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux