On Mon, Oct 24, 2022 at 02:32:59PM -0700, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@xxxxxxxxxx> > > 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. This looks very familiar! :) https://lore.kernel.org/linux-xfs/20210419082804.2076124-1-hch@xxxxxx/ It seems like it might make more sense to start with hch's series, and see what's missing? > > 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. This feels like 3 separate logical changes in a single patch, but, regardless: Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx> This will proactively fix XFS under CONFIG_UBSAN_BOUNDS once -fstrict-flex-arrays is added. Thank you! -- Kees Cook