• Darrick J. Wong's avatar
    xfs: use xfs_defer_pending objects to recover intent items · 03f7767c
    Darrick J. Wong authored
    One thing I never quite got around to doing is porting the log intent
    item recovery code to reconstruct the deferred pending work state.  As a
    result, each intent item open codes xfs_defer_finish_one in its recovery
    method, because that's what the EFI code did before xfs_defer.c even
    existed.
    
    This is a gross thing to have left unfixed -- if an EFI cannot proceed
    due to busy extents, we end up creating separate new EFIs for each
    unfinished work item, which is a change in behavior from what runtime
    would have done.
    
    Worse yet, Long Li pointed out that there's a UAF in the recovery code.
    The ->commit_pass2 function adds the intent item to the AIL and drops
    the refcount.  The one remaining refcount is now owned by the recovery
    mechanism (aka the log intent items in the AIL) with the intent of
    giving the refcount to the intent done item in the ->iop_recover
    function.
    
    However, if something fails later in recovery, xlog_recover_finish will
    walk the recovered intent items in the AIL and release them.  If the CIL
    hasn't been pushed before that point (which is possible since we don't
    force the log until later) then the intent done release will try to free
    its associated intent, which has already been freed.
    
    This patch starts to address this mess by having the ->commit_pass2
    functions recreate the xfs_defer_pending state.  The next few patches
    will fix the recovery functions.
    Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    03f7767c
xfs_defer.c 28.9 KB