]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commit - libxfs/xfs_dir2_block.c
xfs: don't crash on unexpected holes in dir/attr btrees
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 31 Jul 2017 20:08:12 +0000 (15:08 -0500)
committerEric Sandeen <sandeen@redhat.com>
Mon, 31 Jul 2017 20:08:12 +0000 (15:08 -0500)
commita6c6b1bd72f63b2bb05cae185abef0da24e0bf28
tree30d0168b56b7bdb44db4353e4065ebf37222f275
parentb8fb8c95f25ca9d660409f316d131a0796004a4a
xfs: don't crash on unexpected holes in dir/attr btrees

Source kernel commit: cd87d867920155911d0d2e6485b769d853547750

In quite a few places we call xfs_da_read_buf with a mappedbno that we
don't control, then assume that the function passes back either an error
code or a buffer pointer.  Unfortunately, if mappedbno == -2 and bno
maps to a hole, we get a return code of zero and a NULL buffer, which
means that we crash if we actually try to use that buffer pointer.  This
happens immediately when we set the buffer type for transaction context.

Therefore, check that we have no error code and a non-NULL bp before
trying to use bp.  This patch is a follow-up to an incomplete fix in
96a3aefb8ffde231 ("xfs: don't crash if reading a directory results in an
unexpected hole").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_attr_leaf.c
libxfs/xfs_da_btree.c
libxfs/xfs_dir2_block.c
libxfs/xfs_dir2_leaf.c