aboutsummaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_super.c
diff options
context:
space:
mode:
authorGravatar Darrick J. Wong <djwong@kernel.org> 2022-10-20 16:39:59 -0700
committerGravatar Darrick J. Wong <djwong@kernel.org> 2022-10-31 08:58:20 -0700
commit03a7485cd701e1c08baadcf39d9592d83715e224 (patch)
treea35a0f74bb35f910d767d0f6169c5b2201d698d0 /fs/xfs/xfs_super.c
parentxfs: fix memcpy fortify errors in RUI log format copying (diff)
downloadlinux-03a7485cd701e1c08baadcf39d9592d83715e224.tar.gz
linux-03a7485cd701e1c08baadcf39d9592d83715e224.tar.bz2
linux-03a7485cd701e1c08baadcf39d9592d83715e224.zip
xfs: fix memcpy fortify errors in EFI log format copying
Starting in 6.1, CONFIG_FORTIFY_SOURCE checks the length parameter of memcpy. Since we're already fixing problems with BUI item copying, we should fix it everything else. An extra difficulty here is that the ef[id]_extents arrays are declared as single-element arrays. This is not the convention for flex arrays in the modern kernel, and it causes all manner of problems with static checking tools, since they often cannot tell the difference between a single element array and a flex array. So for starters, change those array[1] declarations to array[] declarations to signal that they are proper flex arrays and adjust all the "size-1" expressions to fit the new declaration style. Next, refactor the xfs_efi_copy_format function to handle the copying of the head and the flex array members separately. While we're at it, fix a minor validation deficiency in the recovery function. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Kees Cook <keescook@chromium.org> Reviewed-by: Allison Henderson <allison.henderson@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs/xfs_super.c')
-rw-r--r--fs/xfs/xfs_super.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index f029c6702dda..8485e3b37ca0 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -2029,7 +2029,7 @@ xfs_init_caches(void)
xfs_efd_cache = kmem_cache_create("xfs_efd_item",
(sizeof(struct xfs_efd_log_item) +
- (XFS_EFD_MAX_FAST_EXTENTS - 1) *
+ XFS_EFD_MAX_FAST_EXTENTS *
sizeof(struct xfs_extent)),
0, 0, NULL);
if (!xfs_efd_cache)
@@ -2037,7 +2037,7 @@ xfs_init_caches(void)
xfs_efi_cache = kmem_cache_create("xfs_efi_item",
(sizeof(struct xfs_efi_log_item) +
- (XFS_EFI_MAX_FAST_EXTENTS - 1) *
+ XFS_EFI_MAX_FAST_EXTENTS *
sizeof(struct xfs_extent)),
0, 0, NULL);
if (!xfs_efi_cache)