Skip to content

Commit e92a680

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 openzfs#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 openzfs#15145 Closes openzfs#15510
1 parent f1659cc commit e92a680

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
@@ -108,7 +108,7 @@ typedef struct spl_kmem_magazine {
108108
uint32_t skm_refill; /* Batch refill size */
109109
struct spl_kmem_cache *skm_cache; /* Owned by cache */
110110
unsigned int skm_cpu; /* Owned by cpu */
111-
void *skm_objs[0]; /* Object pointers */
111+
void *skm_objs[]; /* Object pointers */
112112
} spl_kmem_magazine_t;
113113

114114
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
@@ -130,7 +130,7 @@ typedef struct raidz_row {
130130
uint64_t rr_offset; /* Logical offset for *_io_verify() */
131131
uint64_t rr_size; /* Physical size for *_io_verify() */
132132
#endif
133-
raidz_col_t rr_col[0]; /* Flexible array of I/O columns */
133+
raidz_col_t rr_col[]; /* Flexible array of I/O columns */
134134
} raidz_row_t;
135135

136136
typedef struct raidz_map {
@@ -139,7 +139,7 @@ typedef struct raidz_map {
139139
int rm_nskip; /* RAIDZ sectors skipped for padding */
140140
int rm_skipstart; /* Column index of padding start */
141141
const raidz_impl_ops_t *rm_ops; /* RAIDZ math operations */
142-
raidz_row_t *rm_row[0]; /* flexible array of rows */
142+
raidz_row_t *rm_row[]; /* flexible array of rows */
143143
} raidz_map_t;
144144

145145

module/Kbuild.in

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

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

0 commit comments

Comments
 (0)