Re: [PATCH 3/3] xfs: teach deferred op freezer to freeze and thaw inodes

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

 



On Mon, Apr 27, 2020 at 07:37:52AM -0400, Brian Foster wrote:
> On Sat, Apr 25, 2020 at 12:01:37PM -0700, Christoph Hellwig wrote:
> > On Tue, Apr 21, 2020 at 07:08:26PM -0700, Darrick J. Wong wrote:
> > > From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> > > 
> > > Make it so that the deferred operations freezer can save inode numbers
> > > when we freeze the dfops chain, and turn them into pointers to incore
> > > inodes when we thaw the dfops chain to finish them.  Next, add dfops
> > > item freeze and thaw functions to the BUI/BUD items so that they can
> > > take advantage of this new feature.  This fixes a UAF bug in the
> > > deferred bunmapi code because xfs_bui_recover can schedule another BUI
> > > to continue unmapping but drops the inode pointer immediately
> > > afterwards.
> > 
> > I'm only looking over this the first time, but why can't we just keep
> > inode reference around during reocvery instead of this fairly
> > complicated scheme to save the ino and then look it up again?
> > 
> 
> I'm also a little confused about the use after free in the first place.
> Doesn't xfs_bui_recover() look up the inode itself, or is the issue that
> xfs_bui_recover() is fine but we might get into
> xfs_bmap_update_finish_item() sometime later on the same inode without
> any reference?

The second.  In practice it doesn't seem to trigger on the existing
code, but the combination of atomic extent swap + fsstress + shutdown
testing was enough to push it over the edge once due to reclaim.

> If the latter, similarly to Christoph I wonder if we
> really could/should grab a reference on the inode for the intent itself,
> even though that might not be necessary outside of recovery.

Outside of recovery we don't have the UAF problem because there's always
something (usually the VFS dentry cache, but sometimes an explicit iget)
that hold a reference to the inode for the duration of the transaction
and dfops processing.

One could just hang on to all incore inodes until the end of recovery
like Christoph says, but the downside of doing it that way is that now
we require enough memory to maintain all that incore state vs. only
needing enough for the incore inodes involved in a particular dfops
chain.  That isn't a huge deal now, but I was looking ahead to atomic
extent swaps.

(And, yeah, I should put that series on the list now...)

> Either way, more details about the problem being fixed in the commit log
> would be helpful.

<nod>

--D

> Brian
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux