Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

authored by

Darrick J. Wong and committed by
Carlos Maiolino
bd721ec7 0f41997b

+2 -1
+1 -1
fs/xfs/xfs_buf.c
··· 1751 1751 const char *descr) 1752 1752 { 1753 1753 /* The maximum size of the buftarg is only known once the sb is read. */ 1754 - btp->bt_nr_sectors = (xfs_daddr_t)-1; 1754 + btp->bt_nr_sectors = XFS_BUF_DADDR_MAX; 1755 1755 1756 1756 /* Set up device logical sector size mask */ 1757 1757 btp->bt_logical_sectorsize = logical_sectorsize;
+1
fs/xfs/xfs_buf.h
··· 22 22 */ 23 23 struct xfs_buf; 24 24 25 + #define XFS_BUF_DADDR_MAX ((xfs_daddr_t) S64_MAX) 25 26 #define XFS_BUF_DADDR_NULL ((xfs_daddr_t) (-1LL)) 26 27 27 28 #define XBF_READ (1u << 0) /* buffer intended for reading from device */