Re: [PATCH 2/2] xfs: Use flex_cpy() to check extent copying

Andy Shevchenko
2022-10-25T08:58:51Z

On Mon, Oct 24, 2022 at 10:20:58AM -0700, Kees Cook wrote:
> Use flex_cpy() instead of memcpy() to copy the bui_fmt flexible array
> structure, which will perform bounds checking internally. Avoids the
> false positive warning seen under FORTIFY_SOURCE:
>
> memcpy: detected field-spanning write (size 48) of single field "dst_bui_fmt" at fs/xfs/xfs_bmap_item.c:628 (size 16)

...

> #include "xfs_error.h"
> #include "xfs_log_priv.h"
> #include "xfs_log_recover.h"

> +#include <linux/flex_array.h>

Wouldn't it be better to include it before any "local" headers?

--
With Best Regards,
Andy Shevchenko