]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commit
xfs: fix a sloppy memory handling bug in xfs_iroot_realloc
authorDarrick J. Wong <djwong@kernel.org>
Mon, 21 Oct 2024 00:10:44 +0000 (17:10 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:03 +0000 (15:45 -0700)
commit9bd5f52de6587afd4b2f7a1db1c2428133ade02a
tree013ec5027c669a6bfe8cf7b65428474dd4abad0b
parent84704ebf61a2823f324524b8e35f72564e89b660
xfs: fix a sloppy memory handling bug in xfs_iroot_realloc

Source kernel commit: de55149b6639e903c4d06eb0474ab2c05060e61d

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_inode_fork.c