]> 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)
commit6c80b904a2f9216341929841a2ee1e1c23709787
tree83616f4fd6999b0444ba6d46284d303d45f1751a
parent59d489f1028bc312a708eb55d4fa8dbaae80f1ed
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: 2dde20a56062 ("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