]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commit
xfs: fix memcpy fortify errors in EFI log format copying
authorDarrick J. Wong <djwong@kernel.org>
Fri, 18 Nov 2022 09:54:10 +0000 (10:54 +0100)
committerCarlos Maiolino <cem@kernel.org>
Mon, 21 Nov 2022 14:26:48 +0000 (15:26 +0100)
commitd267ac6a00cd57bf6015e34af565f4bdcb4d7e34
tree0fb5510ea79a8bab16f50efaca4095c9cb1cd579
parent227bc97f12f2df902ab776fe038dc6d065f03c58
xfs: fix memcpy fortify errors in EFI log format copying

Source kernel commit: 03a7485cd701e1c08baadcf39d9592d83715e224

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>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_log_format.h
logprint/log_redo.c