Re: [PATCH RFC bpf-next 1/8] kasan: expose generic kasan helpers

sashiko-bot
2026-04-25T03:13:46Z

Sashiko AI review found 1 potential issue(s):
- [Low] The declarations of __asan_loadX and __asan_storeX are conditionally wrapped in `#ifdef CONFIG_KASAN_GENERIC`, which prevents callers from using the standard `IS_ENABLED()` macro.
--

commit a639759513c522c95441b98d740390daf692c6e3
Author: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>

kasan: expose generic kasan helpers

This commit exposes generic KASAN load and store helper functions in
include/linux/kasan.h. It moves the declarations from the internal
mm/kasan/kasan.h header to prepare for their use by the eBPF subsystem.

> diff --git a/include/linux/kasan.h b/include/linux/kasan.h
> index bf233bde68c7e..587b25d170f40 100644
> --- a/include/linux/kasan.h
> +++ b/include/linux/kasan.h
> @@ -710,4 +710,17 @@ void kasan_non_canonical_hook(unsigned long addr);
> static inline void kasan_non_canonical_hook(unsigned long addr) { }
> #endif /* CONFIG_KASAN_GENERIC || CONFIG_KASAN_SW_TAGS */
>
> +#ifdef CONFIG_KASAN_GENERIC

Does wrapping these declarations in #ifdef CONFIG_KASAN_GENERIC prevent
callers from using the IS_ENABLED() macro?

If code attempts to use if (IS_ENABLED(CONFIG_KASAN_GENERIC)) with these
functions, it will fail to compile with an undeclared identifier error
when generic KASAN is disabled.

Declaring these external functions unconditionally in the header allows
callers to adopt the IS_ENABLED() pattern safely instead of relying on
#ifdef blocks in C files.

> +void __asan_load1(void *p);
> +void __asan_store1(void *p);
> +void __asan_load2(void *p);
> +void __asan_store2(void *p);
> +void __asan_load4(void *p);
> +void __asan_store4(void *p);
> +void __asan_load8(void *p);
> +void __asan_store8(void *p);
> +void __asan_load16(void *p);
> +void __asan_store16(void *p);
> +#endif /* CONFIG_KASAN_GENERIC */
> +
> #endif /* LINUX_KASAN_H */

--
Sashiko AI review · https://sashiko.dev/#/patchset/20260413-kasan-v1-0-1a5831230821@bootlin.com?part=1