Re: [PATCH v2 4/4] kasan: use stack_trace_save_shadow

Andrey Konovalov
2022-03-29T18:36:59Z

On Mon, Mar 28, 2022 at 2:49 PM Marco Elver <elver@google.com> wrote:
>
> > diff --git a/mm/kasan/common.c b/mm/kasan/common.c
> > index d9079ec11f31..8d9d35c6562b 100644
> > --- a/mm/kasan/common.c
> > +++ b/mm/kasan/common.c
> > @@ -33,10 +33,13 @@
> > depot_stack_handle_t kasan_save_stack(gfp_t flags, bool can_alloc)
> > {
> > unsigned long entries[KASAN_STACK_DEPTH];
> > - unsigned int nr_entries;
> > + unsigned int size;
>
> Why did this variable name change?

So the lines below fit within one line. It won't be needed with the
other change you suggested.

> > - nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 0);
> > - return __stack_depot_save(entries, nr_entries, flags, can_alloc);
> > + if (IS_ENABLED(CONFIG_HAVE_SHADOW_STACKTRACE))
>
> Would it be more reliable to check the return-code? I.e. do:
>
> int size;
>
> size = stack_trace_save_shadow(...)
> if (size < 0)
> size = stack_trace_save(...);

Sounds good, will do in v3.

Thanks!