Skip to content

Commit 786641d

Browse files
Workaround UBSAN errors for variable arrays
This gets around UBSAN errors when using arrays at the end of structs. It converts some zero-length arrays to variable length arrays and disables UBSAN checking on certain modules. It is based off of the patch from #15460. Reviewed-by: Brian Behlendorf <[email protected]> Tested-by: Thomas Lamprecht <[email protected]> Co-authored-by: Thomas Lamprecht <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Issue #15145 Closes #15510
1 parent 3a8d9b8 commit 786641d

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

include/os/linux/spl/sys/kmem_cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef struct spl_kmem_magazine {
106106
uint32_t skm_refill; /* Batch refill size */
107107
struct spl_kmem_cache *skm_cache; /* Owned by cache */
108108
unsigned int skm_cpu; /* Owned by cpu */
109-
void *skm_objs[0]; /* Object pointers */
109+
void *skm_objs[]; /* Object pointers */
110110
} spl_kmem_magazine_t;
111111

112112
typedef struct spl_kmem_obj {

include/sys/vdev_raidz_impl.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ typedef struct raidz_row {
136136
uint64_t rr_offset; /* Logical offset for *_io_verify() */
137137
uint64_t rr_size; /* Physical size for *_io_verify() */
138138
#endif
139-
raidz_col_t rr_col[0]; /* Flexible array of I/O columns */
139+
raidz_col_t rr_col[]; /* Flexible array of I/O columns */
140140
} raidz_row_t;
141141

142142
typedef struct raidz_map {
@@ -149,7 +149,7 @@ typedef struct raidz_map {
149149
zfs_locked_range_t *rm_lr;
150150
const raidz_impl_ops_t *rm_ops; /* RAIDZ math operations */
151151
raidz_col_t *rm_phys_col; /* if non-NULL, read i/o aggregation */
152-
raidz_row_t *rm_row[0]; /* flexible array of rows */
152+
raidz_row_t *rm_row[]; /* flexible array of rows */
153153
} raidz_map_t;
154154

155155
/*

module/Kbuild.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,10 @@ zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
489489
zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
490490
zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
491491

492+
UBSAN_SANITIZE_zap_leaf.o := n
493+
UBSAN_SANITIZE_zap_micro.o := n
494+
UBSAN_SANITIZE_sa.o := n
495+
492496
# Suppress incorrect warnings from versions of objtool which are not
493497
# aware of x86 EVEX prefix instructions used for AVX512.
494498
OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y

0 commit comments

Comments
 (0)