]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit
xfs: fix an incore inode UAF in xfs_bui_recover
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 12 Nov 2020 22:21:30 +0000 (17:21 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Thu, 12 Nov 2020 22:21:30 +0000 (17:21 -0500)
commit50edfee5cbe1d83785c8a0ea33a87652bb7d7b08
tree35896fb9414bcdef404a0543ef53de11aa240cfd
parentbb6667dc78946f96a7a117bc8385267c620b8a29
xfs: fix an incore inode UAF in xfs_bui_recover

Source kernel commit: ff4ab5e02a0447dd1e290883eb6cd7d94848e590

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>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_inode.h
libxfs/libxfs_api_defs.h
libxfs/rdwr.c
libxfs/xfs_defer.c
libxfs/xfs_defer.h