]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
xfs: fix off-by-one error in fsmap's end_daddr usage
authorDarrick J. Wong <djwong@kernel.org>
Wed, 18 Dec 2024 19:50:52 +0000 (11:50 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Dec 2024 13:02:00 +0000 (14:02 +0100)
commit5ca4ca38bc74c2e39fe11076a0497280edb81960
treedf8824b8447f427f9049b2cb2de3a4a00e6973bc
parent5b935d8b7024c89cb4f510b216d8678eb101243a
xfs: fix off-by-one error in fsmap's end_daddr usage

commit a440a28ddbdcb861150987b4d6e828631656b92f upstream.

In commit ca6448aed4f10a, we created an "end_daddr" variable to fix
fsmap reporting when the end of the range requested falls in the middle
of an unknown (aka free on the rmapbt) region.  Unfortunately, I didn't
notice that the the code sets end_daddr to the last sector of the device
but then uses that quantity to compute the length of the synthesized
mapping.

Zizhi Wo later observed that when end_daddr isn't set, we still don't
report the last fsblock on a device because in that case (aka when
info->last is true), the info->high mapping that we pass to
xfs_getfsmap_group_helper has a startblock that points to the last
fsblock.  This is also wrong because the code uses startblock to
compute the length of the synthesized mapping.

Fix the second problem by setting end_daddr unconditionally, and fix the
first problem by setting start_daddr to one past the end of the range to
query.

Cc: <stable@vger.kernel.org> # v6.11
Fixes: ca6448aed4f10a ("xfs: Fix missing interval for missing_owner in xfs fsmap")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reported-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/xfs/xfs_fsmap.c