]> git.ipfire.org Git - thirdparty/linux.git/commit
xfs: don't set bt_nr_sectors to a negative number
authorDarrick J. Wong <djwong@kernel.org>
Tue, 21 Oct 2025 18:29:56 +0000 (11:29 -0700)
committerCarlos Maiolino <cem@kernel.org>
Wed, 22 Oct 2025 08:04:39 +0000 (10:04 +0200)
commitbd721ec7dedcc24ced51559e42a39140b59dfd08
treec6ce989e0e338f6221df25f145ef1aa8d6a96630
parent0f41997b1b2b769b73415512d2afaae80630e4fe
xfs: don't set bt_nr_sectors to a negative number

xfs_daddr_t is a signed type, which means that xfs_buf_map_verify is
using a signed comparison.  This causes problems if bt_nr_sectors is
never overridden (e.g. in the case of an xfbtree for rmap btree repairs)
because even daddr 0 can't pass the verifier test in that case.

Define an explicit max constant and set the initial bt_nr_sectors to a
positive value.

Found by xfs/422.

Cc: stable@vger.kernel.org # v6.18-rc1
Fixes: 42852fe57c6d2a ("xfs: track the number of blocks in each buftarg")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h