]> git.baikalelectronics.ru Git - kernel.git/commit
xfs: ensure inobt record walks always make forward progress
authorDarrick J. Wong <darrick.wong@oracle.com>
Sat, 14 Nov 2020 17:59:22 +0000 (09:59 -0800)
committerDarrick J. Wong <darrick.wong@oracle.com>
Wed, 18 Nov 2020 17:23:51 +0000 (09:23 -0800)
commitfeab611f6fe5fa9e3542fd9bccda25d94fab3468
tree83616f4fd6999b0444ba6d46284d303d45f1751a
parent6bad73c328c0d3d746a65e304fb947fc1aa35bea
xfs: ensure inobt record walks always make forward progress

The aim of the inode btree record iterator function is to call a
callback on every record in the btree.  To avoid having to tear down and
recreate the inode btree cursor around every callback, it caches a
certain number of records in a memory buffer.  After each batch of
callback invocations, we have to perform a btree lookup to find the
next record after where we left off.

However, if the keys of the inode btree are corrupt, the lookup might
put us in the wrong part of the inode btree, causing the walk function
to loop forever.  Therefore, we add extra cursor tracking to make sure
that we never go backwards neither when performing the lookup nor when
jumping to the next inobt record.  This also fixes an off by one error
where upon resume the lookup should have been for the inode /after/ the
point at which we stopped.

Found by fuzzing xfs/460 with keys[2].startino = ones causing bulkstat
and quotacheck to hang.

Fixes: 33efc720fda2 ("xfs: create simplified inode walk function")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
fs/xfs/xfs_iwalk.c