• Darrick J. Wong's avatar
    xfs: fix an incore inode UAF in xfs_bui_recover · ff4ab5e0
    Darrick J. Wong authored
    In xfs_bui_item_recover, there exists a use-after-free bug with regards
    to the inode that is involved in the bmap replay operation.  If the
    mapping operation does not complete, we call xfs_bmap_unmap_extent to
    create a deferred op to finish the unmapping work, and we retain a
    pointer to the incore inode.
    
    Unfortunately, the very next thing we do is commit the transaction and
    drop the inode.  If reclaim tears down the inode before we try to finish
    the defer ops, we dereference garbage and blow up.  Therefore, create a
    way to join inodes to the defer ops freezer so that we can maintain the
    xfs_inode reference until we're done with the inode.
    
    Note: This imposes the requirement that there be enough memory to keep
    every incore inode in memory throughout recovery.
    Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
    Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    ff4ab5e0
xfs_log_recover.c 97.6 KB