Re: [PATCH] kasan: Remove kasan_record_aux_stack_noalloc().
From: Sebastian Andrzej Siewior
Date: Fri Nov 22 2024 - 06:32:27 EST
On 2024-11-19 20:36:56 [+0100], Andrey Konovalov wrote:
> > diff --git a/mm/kasan/generic.c b/mm/kasan/generic.c
> > index 6310a180278b6..b18b5944997f8 100644
> > --- a/mm/kasan/generic.c
> > +++ b/mm/kasan/generic.c
> > @@ -521,7 +521,7 @@ size_t kasan_metadata_size(struct kmem_cache *cache, bool in_object)
> > sizeof(struct kasan_free_meta) : 0);
> > }
> >
> > -static void __kasan_record_aux_stack(void *addr, depot_flags_t depot_flags)
>
> Could you add a comment here that notes the usage, something like:
>
> "This function avoids dynamic memory allocations and thus can be
> called from contexts that do not allow allocating memory."
>
> > +void kasan_record_aux_stack(void *addr)
> > {
…
Added but would prefer to add a pointer to stack_depot_save_flags()
which has this Context: paragraph. Would that work?
Now looking at it, it says:
| * Context: Any context, but setting STACK_DEPOT_FLAG_CAN_ALLOC is required if
| * alloc_pages() cannot be used from the current context. Currently
| * this is the case for contexts where neither %GFP_ATOMIC nor
| * %GFP_NOWAIT can be used (NMI, raw_spin_lock).
If I understand this correctly then STACK_DEPOT_FLAG_CAN_ALLOC must not
be specified if invoked from NMI. This will stop
stack_depot_save_flags() from allocating memory the function will still
acquire pool_lock, right?
Do we need to update the comment saying that it must not be used from
NMI or do we make it jump over the locked section in the NMI case?
Sebastian