Hi, Here's a trimmed-down version of my original proposal, which just includes flex_cpy(), as this is needed by XFS. -Kees v2: only include flex_cpy(), leaving remaining helpers for the future v1: https://lore.kernel.org/all/20220504014440.3697851-1-keescook@xxxxxxxxxxxx/ Kees Cook (2): Introduce flexible array struct helpers xfs: Use flex_cpy() to check extent copying fs/xfs/xfs_bmap_item.c | 7 +- include/linux/flex_array.h | 325 ++++++++++++++++++++++++++++++++++++ include/linux/string.h | 1 + include/uapi/linux/stddef.h | 14 ++ 4 files changed, 344 insertions(+), 3 deletions(-) create mode 100644 include/linux/flex_array.h -- 2.34.1