]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: fix pointer arithmetic error on 32-bit systems
authorDarrick J. Wong <djwong@kernel.org>
Wed, 10 Jun 2026 04:57:24 +0000 (21:57 -0700)
committerCarlos Maiolino <cem@kernel.org>
Wed, 10 Jun 2026 10:21:52 +0000 (12:21 +0200)
The translation of the old XFS_BMBT_KEY_ADDR macro into a static
function is not correct on 32-bit systems because the sizeof() argument
went from being a xfs_bmbt_key_t (i.e. a struct) to a (struct
xfs_bmbt_key *) (i.e. a pointer to the same struct).  On 64-bit systems
this turns out ok because they are the same size, but on 32-bit systems
this is catastrophic because they are not the same size.  So far there
have been no complaints, most likely because the xfs developers urge
against running it on 32-bit systems.  But this needs fixing asap.

Cc: stable@vger.kernel.org # v6.12
Fixes: 79124b37400635 ("xfs: replace shouty XFS_BM{BT,DR} macros")
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/libxfs/xfs_bmap_btree.h

index b238d559ab036999ba10f1ef8702ecaca52840b2..e0c870beaf670c20ec4823c43f8bde4b8c63aa68 100644 (file)
@@ -89,7 +89,7 @@ xfs_bmbt_key_addr(
 {
        return (struct xfs_bmbt_key *)
                ((char *)block + xfs_bmbt_block_len(mp) +
-                (index - 1) * sizeof(struct xfs_bmbt_key *));
+                (index - 1) * sizeof(struct xfs_bmbt_key));
 }
 
 static inline xfs_bmbt_ptr_t *