]> www.infradead.org Git - users/hch/xfs.git/commit
xfs: fix a sloppy memory handling bug in xfs_iroot_realloc
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:27 +0000 (21:11 -0700)
committerChristoph Hellwig <hch@lst.de>
Mon, 12 Aug 2024 07:35:27 +0000 (09:35 +0200)
commite46d6834c56932e5ca7dc9cba59bc39f3908164b
tree0368657982bde81d32b7af3aa67671f972b886a5
parent02801887143dac729c5c3fc5ad722b2bce3a1741
xfs: fix a sloppy memory handling bug in xfs_iroot_realloc

While refactoring code, I noticed that when xfs_iroot_realloc tries to
shrink a bmbt root block, it allocates a smaller new block and then
copies "records" and pointers to the new block.  However, bmbt root
blocks cannot ever be leaves, which means that it's not technically
correct to copy records.  We /should/ be copying keys.

Note that this has never resulted in actual memory corruption because
sizeof(bmbt_rec) == (sizeof(bmbt_key) + sizeof(bmbt_ptr)).  However,
this will no longer be true when we start adding realtime rmap stuff,
so fix this now.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/libxfs/xfs_inode_fork.c