From 40a87651d49aadd4370c5a87590651d6e11e498c Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Mon, 18 May 2026 05:13:59 +1000 Subject: [PATCH] zap_impl: use flex array field for mzap_phys_t.mz_chunks mz_phys_t is always a full-block allocation, with mz_chunks[] as an array over the rest of the block past the header. Recent Linux compiled with CONFIG_UBSAN will complain about this: UBSAN: array-index-out-of-bounds in module/zfs/zap.c:1236:28 index 2 is out of range for type 'mzap_ent_phys_t [1]' The fix is straightforward; simply convert this field to a flex member. Sponsored-by: TrueNAS Reviewed-by: Brian Behlendorf Signed-off-by: Rob Norris Closes #18550 --- include/sys/zap_impl.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/sys/zap_impl.h b/include/sys/zap_impl.h index 6c72cd977c8..ea8963f550f 100644 --- a/include/sys/zap_impl.h +++ b/include/sys/zap_impl.h @@ -62,8 +62,9 @@ typedef struct mzap_phys { uint64_t mz_salt; uint64_t mz_normflags; uint64_t mz_pad[5]; - mzap_ent_phys_t mz_chunk[1]; + /* actually variable size depending on block size */ + mzap_ent_phys_t mz_chunk[]; } mzap_phys_t; typedef struct mzap_ent {