]> www.infradead.org Git - users/hch/xfsprogs.git/commit
xfs: fix a sloppy memory handling bug in xfs_iroot_realloc
authorDarrick J. Wong <djwong@kernel.org>
Tue, 9 Jan 2024 17:40:05 +0000 (09:40 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Wed, 10 Apr 2024 00:21:41 +0000 (17:21 -0700)
commit0ff43ce78a7de3e7ac839a8d64e37efda8f16df3
tree5578d6387fd3dfc3c7186e4110e1ec9b27c09b4b
parente296ea6aa2f9c14e037872df6fc467cab9845e6f
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>
libxfs/xfs_inode_fork.c