aboutsummaryrefslogtreecommitdiffstats
path: root/module/zstd
diff options
context:
space:
mode:
authorDamian Szuberski <[email protected]>2022-02-03 23:35:38 +0100
committerGitHub <[email protected]>2022-02-03 14:35:38 -0800
commit63652e154643cfe596fe077c13de0e7be34dd863 (patch)
treea357fcff504f2b8fbdce59b236788435556b45f8 /module/zstd
parentaa9905d89b3559e1cd280d018615d392f57a18d0 (diff)
Add `--enable-asan` and `--enable-ubsan` switches
`configure` now accepts `--enable-asan` and `--enable-ubsan` switches which results in passing `-fsanitize=address` and `-fsanitize=undefined`, respectively, to the compiler. Those flags are enabled in GitHub workflows for ZTS and zloop. Errors reported by both instrumentations are corrected, except for: - Memory leak reporting is (temporarily) suppressed. The cost of fixing them is relatively high compared to the gains. - Checksum computing functions in `module/zcommon/zfs_fletcher*` have UBSan errors suppressed. It is completely impractical to enforce 64-byte payload alignment there due to performance impact. - There's no ASan heap poisoning in `module/zstd/lib/zstd.c`. A custom memory allocator is used there rendering that measure unfeasible. - Memory leaks detection has to be suppressed for `cmd/zvol_id`. `zvol_id` is run by udev with the help of `ptrace(2)`. Tracing is incompatible with memory leaks detection. Reviewed-by: Ahelenia ZiemiaƄska <[email protected]> Reviewed-by: George Melikov <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: szubersk <[email protected]> Closes #12928
Diffstat (limited to 'module/zstd')
-rw-r--r--module/zstd/lib/zstd.c7
-rw-r--r--module/zstd/zfs_zstd.c6
2 files changed, 3 insertions, 10 deletions
diff --git a/module/zstd/lib/zstd.c b/module/zstd/lib/zstd.c
index 2766e5b74..b57a9ef40 100644
--- a/module/zstd/lib/zstd.c
+++ b/module/zstd/lib/zstd.c
@@ -279,12 +279,9 @@ intptr_t __msan_test_shadow(const volatile void *x, size_t size);
#endif
/* detects whether we are being compiled under asan */
-#if defined (__has_feature)
-# if __has_feature(address_sanitizer)
-# define ADDRESS_SANITIZER 1
-# endif
-#elif defined(__SANITIZE_ADDRESS__)
+#if defined (ZFS_ASAN_ENABLED)
# define ADDRESS_SANITIZER 1
+# define ZSTD_ASAN_DONT_POISON_WORKSPACE
#endif
#if defined (ADDRESS_SANITIZER)
diff --git a/module/zstd/zfs_zstd.c b/module/zstd/zfs_zstd.c
index 2c698716c..9ff9ec3ec 100644
--- a/module/zstd/zfs_zstd.c
+++ b/module/zstd/zfs_zstd.c
@@ -207,11 +207,7 @@ static struct zstd_pool *zstd_mempool_dctx;
* and while ASAN does this, KASAN defines that and does not. So to avoid
* changing the external code, we do this.
*/
-#if defined(__has_feature)
-#if __has_feature(address_sanitizer)
-#define ADDRESS_SANITIZER 1
-#endif
-#elif defined(__SANITIZE_ADDRESS__)
+#if defined(ZFS_ASAN_ENABLED)
#define ADDRESS_SANITIZER 1
#endif
#if defined(_KERNEL) && defined(ADDRESS_SANITIZER)