A fake d_name[0]/d_names[0] flexible array tickled UBSAN. Use DECLARE_FLEX_ARRAY to work around a compiler restriction on flex arrays in unions: https://people.kernel.org/kees/bounded-flexible-arrays-in-c
Fixes: "bcachefs: bcachefs_metadata_version_casefolding" Closes: https://github.com/koverstreet/bcachefs/issues/824 Signed-off-by: Gabriel de Perthuis <[email protected]> --- fs/bcachefs/dirent_format.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/bcachefs/dirent_format.h b/fs/bcachefs/dirent_format.h index 2e766032e1e91..a46dbddd21aad 100644 --- a/fs/bcachefs/dirent_format.h +++ b/fs/bcachefs/dirent_format.h @@ -42,13 +42,13 @@ struct bch_dirent { union { struct { __u8 d_pad; __le16 d_name_len; __le16 d_cf_name_len; - __u8 d_names[0]; + __u8 d_names[]; } d_cf_name_block __packed; - __u8 d_name[0]; + __DECLARE_FLEX_ARRAY(__u8, d_name); } __packed; } __packed __aligned(8); #define DT_SUBVOL 16 #define BCH_DT_MAX 17 -- 2.45.2
