linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 3/6] kasan: print timer and workqueue stack
@ 2020-09-24  4:05 Walter Wu
  2020-09-24 11:47 ` Alexander Potapenko
  0 siblings, 1 reply; 5+ messages in thread
From: Walter Wu @ 2020-09-24  4:05 UTC (permalink / raw)
  To: Andrew Morton, Marco Elver, Andrey Ryabinin, Alexander Potapenko,
	Dmitry Vyukov, Andrey Konovalov, Matthias Brugger
  Cc: kasan-dev, linux-mm, linux-kernel, linux-arm-kernel,
	wsd_upstream, linux-mediatek, Walter Wu

The aux_stack[2] is reused to record the call_rcu() call stack,
timer init call stack, and enqueuing work call stacks. So that
we need to change the auxiliary stack title for common title,
print them in KASAN report.

Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
Suggested-by: Marco Elver <elver@google.com>
Acked-by: Marco Elver <elver@google.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Alexander Potapenko <glider@google.com>
---

v2:
- Thanks for Marco suggestion.
- We modify aux stack title name in KASAN report
  in order to print call_rcu()/timer/workqueue stack.

---
 mm/kasan/report.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mm/kasan/report.c b/mm/kasan/report.c
index 4f49fa6cd1aa..886809d0a8dd 100644
--- a/mm/kasan/report.c
+++ b/mm/kasan/report.c
@@ -183,12 +183,12 @@ static void describe_object(struct kmem_cache *cache, void *object,
 
 #ifdef CONFIG_KASAN_GENERIC
 		if (alloc_info->aux_stack[0]) {
-			pr_err("Last call_rcu():\n");
+			pr_err("Last potentially related work creation:\n");
 			print_stack(alloc_info->aux_stack[0]);
 			pr_err("\n");
 		}
 		if (alloc_info->aux_stack[1]) {
-			pr_err("Second to last call_rcu():\n");
+			pr_err("Second to last potentially related work creation:\n");
 			print_stack(alloc_info->aux_stack[1]);
 			pr_err("\n");
 		}
-- 
2.18.0

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 3/6] kasan: print timer and workqueue stack
  2020-09-24  4:05 [PATCH v4 3/6] kasan: print timer and workqueue stack Walter Wu
@ 2020-09-24 11:47 ` Alexander Potapenko
  2020-09-24 11:54   ` Marco Elver
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Potapenko @ 2020-09-24 11:47 UTC (permalink / raw)
  To: Walter Wu
  Cc: Andrew Morton, Marco Elver, Andrey Ryabinin, Dmitry Vyukov,
	Andrey Konovalov, Matthias Brugger, kasan-dev,
	Linux Memory Management List, LKML, Linux ARM, wsd_upstream,
	linux-mediatek

On Thu, Sep 24, 2020 at 6:05 AM Walter Wu <walter-zh.wu@mediatek.com> wrote:
>
> The aux_stack[2] is reused to record the call_rcu() call stack,
> timer init call stack, and enqueuing work call stacks. So that
> we need to change the auxiliary stack title for common title,
> print them in KASAN report.
>
> Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
> Suggested-by: Marco Elver <elver@google.com>
> Acked-by: Marco Elver <elver@google.com>
> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
> Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Cc: Alexander Potapenko <glider@google.com>
> ---
>
> v2:
> - Thanks for Marco suggestion.
> - We modify aux stack title name in KASAN report
>   in order to print call_rcu()/timer/workqueue stack.
>
> ---
>  mm/kasan/report.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> index 4f49fa6cd1aa..886809d0a8dd 100644
> --- a/mm/kasan/report.c
> +++ b/mm/kasan/report.c
> @@ -183,12 +183,12 @@ static void describe_object(struct kmem_cache *cache, void *object,
>
>  #ifdef CONFIG_KASAN_GENERIC
>                 if (alloc_info->aux_stack[0]) {
> -                       pr_err("Last call_rcu():\n");
> +                       pr_err("Last potentially related work creation:\n");

This doesn't have to be a work creation (expect more callers of
kasan_record_aux_stack() in the future), so maybe change the wording
here to "Last potentially related auxiliary stack"?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 3/6] kasan: print timer and workqueue stack
  2020-09-24 11:47 ` Alexander Potapenko
@ 2020-09-24 11:54   ` Marco Elver
  2020-09-24 12:11     ` Alexander Potapenko
  0 siblings, 1 reply; 5+ messages in thread
From: Marco Elver @ 2020-09-24 11:54 UTC (permalink / raw)
  To: Alexander Potapenko
  Cc: Walter Wu, Andrew Morton, Andrey Ryabinin, Dmitry Vyukov,
	Andrey Konovalov, Matthias Brugger, kasan-dev,
	Linux Memory Management List, LKML, Linux ARM, wsd_upstream,
	linux-mediatek

On Thu, 24 Sep 2020 at 13:47, Alexander Potapenko <glider@google.com> wrote:
>
> On Thu, Sep 24, 2020 at 6:05 AM Walter Wu <walter-zh.wu@mediatek.com> wrote:
> >
> > The aux_stack[2] is reused to record the call_rcu() call stack,
> > timer init call stack, and enqueuing work call stacks. So that
> > we need to change the auxiliary stack title for common title,
> > print them in KASAN report.
> >
> > Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
> > Suggested-by: Marco Elver <elver@google.com>
> > Acked-by: Marco Elver <elver@google.com>
> > Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
> > Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
> > Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
> > Cc: Alexander Potapenko <glider@google.com>
> > ---
> >
> > v2:
> > - Thanks for Marco suggestion.
> > - We modify aux stack title name in KASAN report
> >   in order to print call_rcu()/timer/workqueue stack.
> >
> > ---
> >  mm/kasan/report.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> > index 4f49fa6cd1aa..886809d0a8dd 100644
> > --- a/mm/kasan/report.c
> > +++ b/mm/kasan/report.c
> > @@ -183,12 +183,12 @@ static void describe_object(struct kmem_cache *cache, void *object,
> >
> >  #ifdef CONFIG_KASAN_GENERIC
> >                 if (alloc_info->aux_stack[0]) {
> > -                       pr_err("Last call_rcu():\n");
> > +                       pr_err("Last potentially related work creation:\n");
>
> This doesn't have to be a work creation (expect more callers of
> kasan_record_aux_stack() in the future), so maybe change the wording
> here to "Last potentially related auxiliary stack"?

I suggested "work creation" as it's the most precise for what it is
used for now.

What other users do you have in mind in future that are not work creation?


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 3/6] kasan: print timer and workqueue stack
  2020-09-24 11:54   ` Marco Elver
@ 2020-09-24 12:11     ` Alexander Potapenko
  2020-09-24 12:21       ` Marco Elver
  0 siblings, 1 reply; 5+ messages in thread
From: Alexander Potapenko @ 2020-09-24 12:11 UTC (permalink / raw)
  To: Marco Elver
  Cc: Walter Wu, Andrew Morton, Andrey Ryabinin, Dmitry Vyukov,
	Andrey Konovalov, Matthias Brugger, kasan-dev,
	Linux Memory Management List, LKML, Linux ARM, wsd_upstream,
	linux-mediatek

On Thu, Sep 24, 2020 at 1:55 PM Marco Elver <elver@google.com> wrote:
>
> On Thu, 24 Sep 2020 at 13:47, Alexander Potapenko <glider@google.com> wrote:
> >
> > On Thu, Sep 24, 2020 at 6:05 AM Walter Wu <walter-zh.wu@mediatek.com> wrote:
> > >
> > > The aux_stack[2] is reused to record the call_rcu() call stack,
> > > timer init call stack, and enqueuing work call stacks. So that
> > > we need to change the auxiliary stack title for common title,
> > > print them in KASAN report.
> > >
> > > Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
> > > Suggested-by: Marco Elver <elver@google.com>
> > > Acked-by: Marco Elver <elver@google.com>
> > > Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
> > > Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
> > > Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
> > > Cc: Alexander Potapenko <glider@google.com>
> > > ---
> > >
> > > v2:
> > > - Thanks for Marco suggestion.
> > > - We modify aux stack title name in KASAN report
> > >   in order to print call_rcu()/timer/workqueue stack.
> > >
> > > ---
> > >  mm/kasan/report.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> > > index 4f49fa6cd1aa..886809d0a8dd 100644
> > > --- a/mm/kasan/report.c
> > > +++ b/mm/kasan/report.c
> > > @@ -183,12 +183,12 @@ static void describe_object(struct kmem_cache *cache, void *object,
> > >
> > >  #ifdef CONFIG_KASAN_GENERIC
> > >                 if (alloc_info->aux_stack[0]) {
> > > -                       pr_err("Last call_rcu():\n");
> > > +                       pr_err("Last potentially related work creation:\n");
> >
> > This doesn't have to be a work creation (expect more callers of
> > kasan_record_aux_stack() in the future), so maybe change the wording
> > here to "Last potentially related auxiliary stack"?
>
> I suggested "work creation" as it's the most precise for what it is
> used for now.

I see, then maybe my suggestion is premature.

> What other users do you have in mind in future that are not work creation?

I think saving stacks may help in any case where an object is reused
for a different purpose without reallocation.
SKBs, maybe?


--
Alexander Potapenko
Software Engineer

Google Germany GmbH
Erika-Mann-Straße, 33
80636 München

Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4 3/6] kasan: print timer and workqueue stack
  2020-09-24 12:11     ` Alexander Potapenko
@ 2020-09-24 12:21       ` Marco Elver
  0 siblings, 0 replies; 5+ messages in thread
From: Marco Elver @ 2020-09-24 12:21 UTC (permalink / raw)
  To: Alexander Potapenko
  Cc: Walter Wu, Andrew Morton, Andrey Ryabinin, Dmitry Vyukov,
	Andrey Konovalov, Matthias Brugger, kasan-dev,
	Linux Memory Management List, LKML, Linux ARM, wsd_upstream,
	linux-mediatek

On Thu, 24 Sep 2020 at 14:11, Alexander Potapenko <glider@google.com> wrote:
>
> On Thu, Sep 24, 2020 at 1:55 PM Marco Elver <elver@google.com> wrote:
> >
> > On Thu, 24 Sep 2020 at 13:47, Alexander Potapenko <glider@google.com> wrote:
> > >
> > > On Thu, Sep 24, 2020 at 6:05 AM Walter Wu <walter-zh.wu@mediatek.com> wrote:
> > > >
> > > > The aux_stack[2] is reused to record the call_rcu() call stack,
> > > > timer init call stack, and enqueuing work call stacks. So that
> > > > we need to change the auxiliary stack title for common title,
> > > > print them in KASAN report.
> > > >
> > > > Signed-off-by: Walter Wu <walter-zh.wu@mediatek.com>
> > > > Suggested-by: Marco Elver <elver@google.com>
> > > > Acked-by: Marco Elver <elver@google.com>
> > > > Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
> > > > Reviewed-by: Andrey Konovalov <andreyknvl@google.com>
> > > > Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
> > > > Cc: Alexander Potapenko <glider@google.com>
> > > > ---
> > > >
> > > > v2:
> > > > - Thanks for Marco suggestion.
> > > > - We modify aux stack title name in KASAN report
> > > >   in order to print call_rcu()/timer/workqueue stack.
> > > >
> > > > ---
> > > >  mm/kasan/report.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/mm/kasan/report.c b/mm/kasan/report.c
> > > > index 4f49fa6cd1aa..886809d0a8dd 100644
> > > > --- a/mm/kasan/report.c
> > > > +++ b/mm/kasan/report.c
> > > > @@ -183,12 +183,12 @@ static void describe_object(struct kmem_cache *cache, void *object,
> > > >
> > > >  #ifdef CONFIG_KASAN_GENERIC
> > > >                 if (alloc_info->aux_stack[0]) {
> > > > -                       pr_err("Last call_rcu():\n");
> > > > +                       pr_err("Last potentially related work creation:\n");
> > >
> > > This doesn't have to be a work creation (expect more callers of
> > > kasan_record_aux_stack() in the future), so maybe change the wording
> > > here to "Last potentially related auxiliary stack"?
> >
> > I suggested "work creation" as it's the most precise for what it is
> > used for now.
>
> I see, then maybe my suggestion is premature.
>
> > What other users do you have in mind in future that are not work creation?
>
> I think saving stacks may help in any case where an object is reused
> for a different purpose without reallocation.
> SKBs, maybe?

I currently don't know, it's hard to say without having a report that
we can't debug without it.

The litmus test for if it's useful would probably be "do we need this
stacktrace to debug a use-after-free/double-free?". If the answer is
maybe (and not yes!), I'd err on the side of not going overboard with
these, because we only have limited storage anyway. "Work creation" is
a clear case of "we loose information to the original caller" and need
it to debug. But of course, if there are similar issues elsewhere, we
need to identify them and then decide if we need it.


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-24 12:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-24  4:05 [PATCH v4 3/6] kasan: print timer and workqueue stack Walter Wu
2020-09-24 11:47 ` Alexander Potapenko
2020-09-24 11:54   ` Marco Elver
2020-09-24 12:11     ` Alexander Potapenko
2020-09-24 12:21       ` Marco Elver

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).