]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: don't crash on unexpected holes in dir/attr btrees
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 8 Jul 2017 01:55:17 +0000 (18:55 -0700)
committerDarrick J. Wong <darrick.wong@oracle.com>
Sat, 8 Jul 2017 01:55:17 +0000 (18:55 -0700)
commitf184d4503de07dc8ba33968b80e7c44dd941d6bb
tree8f9a2c8e14204eeb8823ff67a94e3386e4313120
parentc7106b5bfb4c4051a1f08b6a8e56a6d1fbe00886
xfs: don't crash on unexpected holes in dir/attr btrees

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
fbda303e2c73af22 ("xfs: don't crash if reading a directory results in an
unexpected hole").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_da_btree.c
fs/xfs/libxfs/xfs_dir2_block.c
fs/xfs/libxfs/xfs_dir2_leaf.c