On Mon, Apr 13, 2026 at 8:29 PM Alexis Lothoré (eBPF Foundation) <[email protected]> wrote: > > In order to prepare KASAN helpers to be called from the eBPF subsystem > (to add KASAN instrumentation at runtime when JITing eBPF programs), > expose the __asan_{load,store}X functions in linux/kasan.h > > Signed-off-by: Alexis Lothoré (eBPF Foundation) <[email protected]> > --- > include/linux/kasan.h | 13 +++++++++++++ > mm/kasan/kasan.h | 10 ---------- > 2 files changed, 13 insertions(+), 10 deletions(-) > > diff --git a/include/linux/kasan.h b/include/linux/kasan.h > index 338a1921a50a..6f580d4a39e4 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 > +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 */
This looks ugly, let's not do this unless it's really required. You can just use kasan_check_read/write() instead - these are public wrappers around the same shadow memory checking functions. And they also work with the SW_TAGS mode, in case the BPF would want to use that mode at some point. (For HW_TAGS, we only have kasan_check_byte() that checks a single byte, but it can be extended in the future if required to be used by BPF.) > + > #endif /* LINUX_KASAN_H */ > diff --git a/mm/kasan/kasan.h b/mm/kasan/kasan.h > index fc9169a54766..3bfce8eb3135 100644 > --- a/mm/kasan/kasan.h > +++ b/mm/kasan/kasan.h > @@ -594,16 +594,6 @@ void __asan_handle_no_return(void); > void __asan_alloca_poison(void *, ssize_t size); > void __asan_allocas_unpoison(void *stack_top, ssize_t stack_bottom); > > -void __asan_load1(void *); > -void __asan_store1(void *); > -void __asan_load2(void *); > -void __asan_store2(void *); > -void __asan_load4(void *); > -void __asan_store4(void *); > -void __asan_load8(void *); > -void __asan_store8(void *); > -void __asan_load16(void *); > -void __asan_store16(void *); > void __asan_loadN(void *, ssize_t size); > void __asan_storeN(void *, ssize_t size); > > > -- > 2.53.0 >

