diff mbox series

[RFC,v3,11/36] kmsan: stackdepot: don't allocate KMSAN metadata for stackdepot

Message ID 20191122112621.204798-12-glider@google.com (mailing list archive)
State New, archived
Headers show
Series Add KernelMemorySanitizer infrastructure | expand

Commit Message

Alexander Potapenko Nov. 22, 2019, 11:25 a.m. UTC
We assume nothing interesting could happen in stackdepot, and save some
memory by not tracking stackdepot allocations with KMSAN.

Signed-off-by: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-mm@kvack.org
---

Change-Id: Ic3ec9b3dff3fff2732d874508a3582fb26ff0b1f
---
 lib/stackdepot.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Andrey Konovalov Nov. 29, 2019, 2:52 p.m. UTC | #1
On Fri, Nov 22, 2019 at 12:27 PM <glider@google.com> wrote:
>
> We assume nothing interesting could happen in stackdepot, and save some
> memory by not tracking stackdepot allocations with KMSAN.

I think it makes sense to clarify here that "nothing interesting"
means no uninitialized memory can come from stackdepot or something
like that.

>
> Signed-off-by: Alexander Potapenko <glider@google.com>
> Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
> Cc: Jens Axboe <axboe@kernel.dk>
> Cc: Andy Lutomirski <luto@kernel.org>
> Cc: Vegard Nossum <vegard.nossum@oracle.com>
> Cc: Dmitry Vyukov <dvyukov@google.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-mm@kvack.org
> ---
>
> Change-Id: Ic3ec9b3dff3fff2732d874508a3582fb26ff0b1f
> ---
>  lib/stackdepot.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/lib/stackdepot.c b/lib/stackdepot.c
> index e2f000a9fad8..2b053c429454 100644
> --- a/lib/stackdepot.c
> +++ b/lib/stackdepot.c
> @@ -294,7 +294,8 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
>                  * contexts and I/O.
>                  */
>                 alloc_flags &= ~GFP_ZONEMASK;
> -               alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
> +               alloc_flags &= (GFP_ATOMIC | GFP_KERNEL |
> +                               __GFP_NO_KMSAN_SHADOW);
>                 alloc_flags |= __GFP_NOWARN;
>                 page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
>                 if (page)
> --
> 2.24.0.432.g9d3f5f5b63-goog
>
Alexander Potapenko Dec. 3, 2019, 2:27 p.m. UTC | #2
On Fri, Nov 29, 2019 at 3:52 PM Andrey Konovalov <andreyknvl@google.com> wrote:
>
> On Fri, Nov 22, 2019 at 12:27 PM <glider@google.com> wrote:
> >
> > We assume nothing interesting could happen in stackdepot, and save some
> > memory by not tracking stackdepot allocations with KMSAN.
>
> I think it makes sense to clarify here that "nothing interesting"
> means no uninitialized memory can come from stackdepot or something
> like that.
Agreed. Will update the patch description.
I've also noticed this patch does nothing to ensure the allocations
are performed with __GFP_NO_KMSAN_SHADOW.
> >
> > Signed-off-by: Alexander Potapenko <glider@google.com>
> > Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
> > Cc: Jens Axboe <axboe@kernel.dk>
> > Cc: Andy Lutomirski <luto@kernel.org>
> > Cc: Vegard Nossum <vegard.nossum@oracle.com>
> > Cc: Dmitry Vyukov <dvyukov@google.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: linux-mm@kvack.org
> > ---
> >
> > Change-Id: Ic3ec9b3dff3fff2732d874508a3582fb26ff0b1f
> > ---
> >  lib/stackdepot.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/lib/stackdepot.c b/lib/stackdepot.c
> > index e2f000a9fad8..2b053c429454 100644
> > --- a/lib/stackdepot.c
> > +++ b/lib/stackdepot.c
> > @@ -294,7 +294,8 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
> >                  * contexts and I/O.
> >                  */
> >                 alloc_flags &= ~GFP_ZONEMASK;
> > -               alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
> > +               alloc_flags &= (GFP_ATOMIC | GFP_KERNEL |
> > +                               __GFP_NO_KMSAN_SHADOW);
> >                 alloc_flags |= __GFP_NOWARN;
Should have added __GFP_NO_KMSAN_SHADOW here.
> >                 page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
> >                 if (page)
> > --
> > 2.24.0.432.g9d3f5f5b63-goog
> >
diff mbox series

Patch

diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index e2f000a9fad8..2b053c429454 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -294,7 +294,8 @@  depot_stack_handle_t stack_depot_save(unsigned long *entries,
 		 * contexts and I/O.
 		 */
 		alloc_flags &= ~GFP_ZONEMASK;
-		alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
+		alloc_flags &= (GFP_ATOMIC | GFP_KERNEL |
+				__GFP_NO_KMSAN_SHADOW);
 		alloc_flags |= __GFP_NOWARN;
 		page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
 		if (page)