xfs: fix pointer arithmetic error on 32-bit systems
PATCH 1/1 xfs: fix pointer arithmetic error on 32-bit systems
From: Darrick J. Wong <[email protected]>
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.
--- fs/xfs/libxfs/xfs_bmap_btree.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/libxfs/xfs_bmap_btree.h +1 -1
@@ -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 *
Quoted 10 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
The translation of the old
XFS_BMBT_KEY_ADDRmacro into a static function is not correct on 32-bit systems because thesizeof()argument went from being axfs_bmbt_key_t(i.e. a struct) to a (structxfs_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.
Eww. I think we either need working 32-bit CI, or officially mark 32-bit as deprecated..
The fix looks good:
Quoted 10 lines · Darrick J. Wong
The translation of the old
XFS_BMBT_KEY_ADDRmacro into a static function is not correct on 32-bit systems because thesizeof()argument went from being axfs_bmbt_key_t(i.e. a struct) to a (structxfs_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.[...]
Applied to for-next, thanks!
[1/1] xfs: fix pointer arithmetic error on 32-bit systems
commit: 84eec3f7fc73144d1a230c9e8ad92721e37dcaab
Best regards,
Signature · 1 line
Carlos Maiolino <[email protected]>