]> git.proxmox.com Git - zfsonlinux.git/blob - debian/patches/0013-Workaround-UBSAN-errors-for-variable-arrays.patch
cherry-pick fix for data corruption
[zfsonlinux.git] / debian / patches / 0013-Workaround-UBSAN-errors-for-variable-arrays.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Tony Hutter <hutter2@llnl.gov>
3 Date: Thu, 9 Nov 2023 16:43:35 -0800
4 Subject: [PATCH] Workaround UBSAN errors for variable arrays
5
6 This gets around UBSAN errors when using arrays at the end of
7 structs. It converts some zero-length arrays to variable length
8 arrays and disables UBSAN checking on certain modules.
9
10 It is based off of the patch from #15460.
11
12 Addresses: #15145
13 Signed-off-by: Tony Hutter <hutter2@llnl.gov>
14 Co-authored-by: Tony Hutter <hutter2@llnl.gov>
15 Co-authored-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
16 Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17 ---
18 include/os/linux/spl/sys/kmem_cache.h | 2 +-
19 include/sys/vdev_raidz_impl.h | 4 ++--
20 module/Kbuild.in | 4 ++++
21 3 files changed, 7 insertions(+), 3 deletions(-)
22
23 diff --git a/include/os/linux/spl/sys/kmem_cache.h b/include/os/linux/spl/sys/kmem_cache.h
24 index 20eeadc46..82d50b603 100644
25 --- a/include/os/linux/spl/sys/kmem_cache.h
26 +++ b/include/os/linux/spl/sys/kmem_cache.h
27 @@ -108,7 +108,7 @@ typedef struct spl_kmem_magazine {
28 uint32_t skm_refill; /* Batch refill size */
29 struct spl_kmem_cache *skm_cache; /* Owned by cache */
30 unsigned int skm_cpu; /* Owned by cpu */
31 - void *skm_objs[0]; /* Object pointers */
32 + void *skm_objs[]; /* Object pointers */
33 } spl_kmem_magazine_t;
34
35 typedef struct spl_kmem_obj {
36 diff --git a/include/sys/vdev_raidz_impl.h b/include/sys/vdev_raidz_impl.h
37 index c1037fa12..73c26dff1 100644
38 --- a/include/sys/vdev_raidz_impl.h
39 +++ b/include/sys/vdev_raidz_impl.h
40 @@ -130,7 +130,7 @@ typedef struct raidz_row {
41 uint64_t rr_offset; /* Logical offset for *_io_verify() */
42 uint64_t rr_size; /* Physical size for *_io_verify() */
43 #endif
44 - raidz_col_t rr_col[0]; /* Flexible array of I/O columns */
45 + raidz_col_t rr_col[]; /* Flexible array of I/O columns */
46 } raidz_row_t;
47
48 typedef struct raidz_map {
49 @@ -139,7 +139,7 @@ typedef struct raidz_map {
50 int rm_nskip; /* RAIDZ sectors skipped for padding */
51 int rm_skipstart; /* Column index of padding start */
52 const raidz_impl_ops_t *rm_ops; /* RAIDZ math operations */
53 - raidz_row_t *rm_row[0]; /* flexible array of rows */
54 + raidz_row_t *rm_row[]; /* flexible array of rows */
55 } raidz_map_t;
56
57
58 diff --git a/module/Kbuild.in b/module/Kbuild.in
59 index c13217159..b9c284a24 100644
60 --- a/module/Kbuild.in
61 +++ b/module/Kbuild.in
62 @@ -488,6 +488,10 @@ zfs-$(CONFIG_ARM64) += $(addprefix zfs/,$(ZFS_OBJS_ARM64))
63 zfs-$(CONFIG_PPC) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
64 zfs-$(CONFIG_PPC64) += $(addprefix zfs/,$(ZFS_OBJS_PPC_PPC64))
65
66 +UBSAN_SANITIZE_zap_leaf.o := n
67 +UBSAN_SANITIZE_zap_micro.o := n
68 +UBSAN_SANITIZE_sa.o := n
69 +
70 # Suppress incorrect warnings from versions of objtool which are not
71 # aware of x86 EVEX prefix instructions used for AVX512.
72 OBJECT_FILES_NON_STANDARD_vdev_raidz_math_avx512bw.o := y