From ae7e2df014db46beb971ecb40fb1a379e04d541b Mon Sep 17 00:00:00 2001 From: Rich Ercolani Date: Sat, 12 Jun 2021 09:08:46 -0400 Subject: [PATCH] Fix build with KASAN The stock zstd code expects some helpers from ASAN if ADDRESS_SANITIZER is defined. This works fine in userland, but in kernel, KASAN also defines that but not those helpers. So let's make some empty substitutes for that case. Signed-off-by: Rich Ercolani --- module/zstd/zfs_zstd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/zstd/zfs_zstd.c b/module/zstd/zfs_zstd.c index fc1b0359aa69..1fe0e6c1ffbc 100644 --- a/module/zstd/zfs_zstd.c +++ b/module/zstd/zfs_zstd.c @@ -202,6 +202,18 @@ static struct zstd_fallback_mem zstd_dctx_fallback; static struct zstd_pool *zstd_mempool_cctx; static struct zstd_pool *zstd_mempool_dctx; +/* + * The library zstd code expects these if ADDRESS_SANITIZER gets defined, + * and while ASAN does this, KASAN defines that and does not. So to avoid + * changing the external code, we do this. + */ +#if defined(_KERNEL) && defined(ADDRESS_SANITIZER) +void __asan_unpoison_memory_region(void const volatile *addr, size_t size); +void __asan_poison_memory_region(void const volatile *addr, size_t size); +void __asan_unpoison_memory_region(void const volatile *addr, size_t size) {}; +void __asan_poison_memory_region(void const volatile *addr, size_t size) {}; +#endif + static void zstd_mempool_reap(struct zstd_pool *zstd_mempool)