summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_bmap_item.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2020-05-15 17:16:37 -0700
committerDarrick J. Wong <darrick.wong@oracle.com>2020-06-01 21:16:47 -0700
commitd58d95cbbc5ae1010731b8cf0f276e98ed17f135 (patch)
tree45975dc9810e3f3ee9553a13563d5b24b4afda19 /fs/xfs/xfs_bmap_item.c
parente891f9ca97b6af70d8385d75e6cea62307ec02cc (diff)
xfs: fix an incore inode UAF in xfs_bui_recoverfix-log-recovery_2020-06-01
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: Darrick J. Wong <darrick.wong@oracle.com>
Diffstat (limited to 'fs/xfs/xfs_bmap_item.c')
-rw-r--r--fs/xfs/xfs_bmap_item.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/xfs/xfs_bmap_item.c b/fs/xfs/xfs_bmap_item.c
index d1b5554ac457..b901d953cfb8 100644
--- a/fs/xfs/xfs_bmap_item.c
+++ b/fs/xfs/xfs_bmap_item.c
@@ -510,6 +510,9 @@ xfs_bui_item_recover(
/* Commit transaction, which frees tp. */
error = xlog_recover_trans_commit(tp, dfcp);
+ if (error || count == 0)
+ goto err_unlock;
+ error = xfs_defer_capture_inode(*dfcp, ip);
if (error)
goto err_unlock;
return 0;