Skip to content

Commit

Permalink
Fix build with KASAN
Browse files Browse the repository at this point in the history
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 <rincebrain@gmail.com>
  • Loading branch information
rincebrain committed Jun 12, 2021
1 parent ffdf019 commit ae7e2df
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions module/zstd/zfs_zstd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit ae7e2df

Please sign in to comment.