diff mbox series

[v5,09/38] kmsan: stackdepot: don't allocate KMSAN metadata for stackdepot

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

Commit Message

Alexander Potapenko March 25, 2020, 4:12 p.m. UTC
We assume an uninitialized value couldn't come from stackdepot, so
we don't track 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: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: linux-mm@kvack.org
---

v4:
 - set __GFP_NO_KMSAN_SHADOW explicitly for allocations

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

Comments

Andrey Konovalov April 23, 2020, 7:22 p.m. UTC | #1
On Wed, Mar 25, 2020 at 5:13 PM <glider@google.com> wrote:
>
> We assume an uninitialized value couldn't come from stackdepot, so
> we don't track 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: Marco Elver <elver@google.com>
> Cc: Andrey Konovalov <andreyknvl@google.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: linux-mm@kvack.org

Reviewed-by: Andrey Konovalov <andreyknvl@google.com>

> ---
>
> v4:
>  - set __GFP_NO_KMSAN_SHADOW explicitly for allocations
>
> Change-Id: Ic3ec9b3dff3fff2732d874508a3582fb26ff0b1f
> ---
>  lib/stackdepot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/stackdepot.c b/lib/stackdepot.c
> index 195ce3dc7c37e..ba584910ad66b 100644
> --- a/lib/stackdepot.c
> +++ b/lib/stackdepot.c
> @@ -297,7 +297,7 @@ depot_stack_handle_t stack_depot_save(unsigned long *entries,
>                  */
>                 alloc_flags &= ~GFP_ZONEMASK;
>                 alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
> -               alloc_flags |= __GFP_NOWARN;
> +               alloc_flags |= (__GFP_NOWARN | __GFP_NO_KMSAN_SHADOW);
>                 page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
>                 if (page)
>                         prealloc = page_address(page);
> --
> 2.25.1.696.g5e7596f4ac-goog
>
Alexander Potapenko April 25, 2020, 9:46 a.m. UTC | #2
On Thu, Apr 23, 2020 at 9:22 PM Andrey Konovalov <andreyknvl@google.com> wrote:
>
> On Wed, Mar 25, 2020 at 5:13 PM <glider@google.com> wrote:
> >
> > We assume an uninitialized value couldn't come from stackdepot, so
> > we don't track 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: Marco Elver <elver@google.com>
> > Cc: Andrey Konovalov <andreyknvl@google.com>
> > Cc: Christoph Hellwig <hch@lst.de>
> > Cc: linux-mm@kvack.org
>
> Reviewed-by: Andrey Konovalov <andreyknvl@google.com>

Thanks for the review! I figured out we don't need
__GFP_NO_KMSAN_SHADOW anymore, so I won't include this patch in v6.
diff mbox series

Patch

diff --git a/lib/stackdepot.c b/lib/stackdepot.c
index 195ce3dc7c37e..ba584910ad66b 100644
--- a/lib/stackdepot.c
+++ b/lib/stackdepot.c
@@ -297,7 +297,7 @@  depot_stack_handle_t stack_depot_save(unsigned long *entries,
 		 */
 		alloc_flags &= ~GFP_ZONEMASK;
 		alloc_flags &= (GFP_ATOMIC | GFP_KERNEL);
-		alloc_flags |= __GFP_NOWARN;
+		alloc_flags |= (__GFP_NOWARN | __GFP_NO_KMSAN_SHADOW);
 		page = alloc_pages(alloc_flags, STACK_ALLOC_ORDER);
 		if (page)
 			prealloc = page_address(page);