All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next 1/2] mm: disable KCSAN for kmemleak
@ 2020-03-03 19:28 Qian Cai
  2020-03-03 19:28 ` [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr" Qian Cai
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Qian Cai @ 2020-03-03 19:28 UTC (permalink / raw)
  To: akpm; +Cc: elver, catalin.marinas, linux-mm, linux-kernel, Qian Cai

Kmemleak could scan task stacks while plain writes happens to those
stack variables which could results in data races. For example, in
sys_rt_sigaction and do_sigaction(), it could have plain writes in
a 32-byte size. Since the kmemleak does not care about the actual values
of a non-pointer and all do_sigaction() call sites only copy to stack
variables, just disable KCSAN for kmemleak to avoid annotating anything
outside Kmemleak just because Kmemleak scans everything.

Suggested-by: Marco Elver <elver@google.com>
Signed-off-by: Qian Cai <cai@lca.pw>
---
 mm/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/Makefile b/mm/Makefile
index 946754cc66b6..6e263045f0c2 100644
--- a/mm/Makefile
+++ b/mm/Makefile
@@ -14,6 +14,7 @@ KCSAN_SANITIZE_slab_common.o := n
 KCSAN_SANITIZE_slab.o := n
 KCSAN_SANITIZE_slub.o := n
 KCSAN_SANITIZE_page_alloc.o := n
+KCSAN_SANITIZE_kmemleak.o := n
 
 # These files are disabled because they produce non-interesting and/or
 # flaky coverage that is not a function of syscall inputs. E.g. slab is out of
-- 
1.8.3.1


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

* [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr"
  2020-03-03 19:28 [PATCH -next 1/2] mm: disable KCSAN for kmemleak Qian Cai
@ 2020-03-03 19:28 ` Qian Cai
  2020-03-03 20:21     ` Marco Elver
  2020-03-11 14:19   ` Catalin Marinas
  2020-03-03 20:20   ` Marco Elver
  2020-03-11 14:18 ` Catalin Marinas
  2 siblings, 2 replies; 8+ messages in thread
From: Qian Cai @ 2020-03-03 19:28 UTC (permalink / raw)
  To: akpm; +Cc: elver, catalin.marinas, linux-mm, linux-kernel, Qian Cai

This reverts commit a03184297d546c6531cdd40878f1f50732d3bac9.

Signed-off-by: Qian Cai <cai@lca.pw>
---
 mm/kmemleak.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/mm/kmemleak.c b/mm/kmemleak.c
index 788dc5509539..e362dc3d2028 100644
--- a/mm/kmemleak.c
+++ b/mm/kmemleak.c
@@ -1169,12 +1169,7 @@ static bool update_checksum(struct kmemleak_object *object)
 	u32 old_csum = object->checksum;
 
 	kasan_disable_current();
-	/*
-	 * crc32() will dereference object->pointer. If an unstable value was
-	 * returned due to a data race, it will be corrected in the next scan.
-	 */
-	object->checksum = data_race(crc32(0, (void *)object->pointer,
-					   object->size));
+	object->checksum = crc32(0, (void *)object->pointer, object->size);
 	kasan_enable_current();
 
 	return object->checksum != old_csum;
@@ -1248,7 +1243,7 @@ static void scan_block(void *_start, void *_end,
 			break;
 
 		kasan_disable_current();
-		pointer = data_race(*ptr);
+		pointer = *ptr;
 		kasan_enable_current();
 
 		untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer);
-- 
1.8.3.1


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

* Re: [PATCH -next 1/2] mm: disable KCSAN for kmemleak
  2020-03-03 19:28 [PATCH -next 1/2] mm: disable KCSAN for kmemleak Qian Cai
@ 2020-03-03 20:20   ` Marco Elver
  2020-03-03 20:20   ` Marco Elver
  2020-03-11 14:18 ` Catalin Marinas
  2 siblings, 0 replies; 8+ messages in thread
From: Marco Elver @ 2020-03-03 20:20 UTC (permalink / raw)
  To: Qian Cai
  Cc: Andrew Morton, catalin.marinas, Linux Memory Management List, LKML

On Tue, 3 Mar 2020 at 20:28, Qian Cai <cai@lca.pw> wrote:
>
> Kmemleak could scan task stacks while plain writes happens to those
> stack variables which could results in data races. For example, in
> sys_rt_sigaction and do_sigaction(), it could have plain writes in
> a 32-byte size. Since the kmemleak does not care about the actual values
> of a non-pointer and all do_sigaction() call sites only copy to stack
> variables, just disable KCSAN for kmemleak to avoid annotating anything
> outside Kmemleak just because Kmemleak scans everything.
>
> Suggested-by: Marco Elver <elver@google.com>
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Marco Elver <elver@google.com>

Thank you!

> ---
>  mm/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/mm/Makefile b/mm/Makefile
> index 946754cc66b6..6e263045f0c2 100644
> --- a/mm/Makefile
> +++ b/mm/Makefile
> @@ -14,6 +14,7 @@ KCSAN_SANITIZE_slab_common.o := n
>  KCSAN_SANITIZE_slab.o := n
>  KCSAN_SANITIZE_slub.o := n
>  KCSAN_SANITIZE_page_alloc.o := n
> +KCSAN_SANITIZE_kmemleak.o := n
>
>  # These files are disabled because they produce non-interesting and/or
>  # flaky coverage that is not a function of syscall inputs. E.g. slab is out of
> --
> 1.8.3.1
>

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

* Re: [PATCH -next 1/2] mm: disable KCSAN for kmemleak
@ 2020-03-03 20:20   ` Marco Elver
  0 siblings, 0 replies; 8+ messages in thread
From: Marco Elver @ 2020-03-03 20:20 UTC (permalink / raw)
  To: Qian Cai
  Cc: Andrew Morton, catalin.marinas, Linux Memory Management List, LKML

On Tue, 3 Mar 2020 at 20:28, Qian Cai <cai@lca.pw> wrote:
>
> Kmemleak could scan task stacks while plain writes happens to those
> stack variables which could results in data races. For example, in
> sys_rt_sigaction and do_sigaction(), it could have plain writes in
> a 32-byte size. Since the kmemleak does not care about the actual values
> of a non-pointer and all do_sigaction() call sites only copy to stack
> variables, just disable KCSAN for kmemleak to avoid annotating anything
> outside Kmemleak just because Kmemleak scans everything.
>
> Suggested-by: Marco Elver <elver@google.com>
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Marco Elver <elver@google.com>

Thank you!

> ---
>  mm/Makefile | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/mm/Makefile b/mm/Makefile
> index 946754cc66b6..6e263045f0c2 100644
> --- a/mm/Makefile
> +++ b/mm/Makefile
> @@ -14,6 +14,7 @@ KCSAN_SANITIZE_slab_common.o := n
>  KCSAN_SANITIZE_slab.o := n
>  KCSAN_SANITIZE_slub.o := n
>  KCSAN_SANITIZE_page_alloc.o := n
> +KCSAN_SANITIZE_kmemleak.o := n
>
>  # These files are disabled because they produce non-interesting and/or
>  # flaky coverage that is not a function of syscall inputs. E.g. slab is out of
> --
> 1.8.3.1
>


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

* Re: [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr"
  2020-03-03 19:28 ` [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr" Qian Cai
@ 2020-03-03 20:21     ` Marco Elver
  2020-03-11 14:19   ` Catalin Marinas
  1 sibling, 0 replies; 8+ messages in thread
From: Marco Elver @ 2020-03-03 20:21 UTC (permalink / raw)
  To: Qian Cai
  Cc: Andrew Morton, catalin.marinas, Linux Memory Management List, LKML

On Tue, 3 Mar 2020 at 20:28, Qian Cai <cai@lca.pw> wrote:
>
> This reverts commit a03184297d546c6531cdd40878f1f50732d3bac9.
>
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Marco Elver <elver@google.com>

Thank you!

> ---
>  mm/kmemleak.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index 788dc5509539..e362dc3d2028 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -1169,12 +1169,7 @@ static bool update_checksum(struct kmemleak_object *object)
>         u32 old_csum = object->checksum;
>
>         kasan_disable_current();
> -       /*
> -        * crc32() will dereference object->pointer. If an unstable value was
> -        * returned due to a data race, it will be corrected in the next scan.
> -        */
> -       object->checksum = data_race(crc32(0, (void *)object->pointer,
> -                                          object->size));
> +       object->checksum = crc32(0, (void *)object->pointer, object->size);
>         kasan_enable_current();
>
>         return object->checksum != old_csum;
> @@ -1248,7 +1243,7 @@ static void scan_block(void *_start, void *_end,
>                         break;
>
>                 kasan_disable_current();
> -               pointer = data_race(*ptr);
> +               pointer = *ptr;
>                 kasan_enable_current();
>
>                 untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer);
> --
> 1.8.3.1
>

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

* Re: [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr"
@ 2020-03-03 20:21     ` Marco Elver
  0 siblings, 0 replies; 8+ messages in thread
From: Marco Elver @ 2020-03-03 20:21 UTC (permalink / raw)
  To: Qian Cai
  Cc: Andrew Morton, catalin.marinas, Linux Memory Management List, LKML

On Tue, 3 Mar 2020 at 20:28, Qian Cai <cai@lca.pw> wrote:
>
> This reverts commit a03184297d546c6531cdd40878f1f50732d3bac9.
>
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Marco Elver <elver@google.com>

Thank you!

> ---
>  mm/kmemleak.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/mm/kmemleak.c b/mm/kmemleak.c
> index 788dc5509539..e362dc3d2028 100644
> --- a/mm/kmemleak.c
> +++ b/mm/kmemleak.c
> @@ -1169,12 +1169,7 @@ static bool update_checksum(struct kmemleak_object *object)
>         u32 old_csum = object->checksum;
>
>         kasan_disable_current();
> -       /*
> -        * crc32() will dereference object->pointer. If an unstable value was
> -        * returned due to a data race, it will be corrected in the next scan.
> -        */
> -       object->checksum = data_race(crc32(0, (void *)object->pointer,
> -                                          object->size));
> +       object->checksum = crc32(0, (void *)object->pointer, object->size);
>         kasan_enable_current();
>
>         return object->checksum != old_csum;
> @@ -1248,7 +1243,7 @@ static void scan_block(void *_start, void *_end,
>                         break;
>
>                 kasan_disable_current();
> -               pointer = data_race(*ptr);
> +               pointer = *ptr;
>                 kasan_enable_current();
>
>                 untagged_ptr = (unsigned long)kasan_reset_tag((void *)pointer);
> --
> 1.8.3.1
>


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

* Re: [PATCH -next 1/2] mm: disable KCSAN for kmemleak
  2020-03-03 19:28 [PATCH -next 1/2] mm: disable KCSAN for kmemleak Qian Cai
  2020-03-03 19:28 ` [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr" Qian Cai
  2020-03-03 20:20   ` Marco Elver
@ 2020-03-11 14:18 ` Catalin Marinas
  2 siblings, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2020-03-11 14:18 UTC (permalink / raw)
  To: Qian Cai; +Cc: akpm, elver, linux-mm, linux-kernel

On Tue, Mar 03, 2020 at 02:28:35PM -0500, Qian Cai wrote:
> Kmemleak could scan task stacks while plain writes happens to those
> stack variables which could results in data races. For example, in
> sys_rt_sigaction and do_sigaction(), it could have plain writes in
> a 32-byte size. Since the kmemleak does not care about the actual values
> of a non-pointer and all do_sigaction() call sites only copy to stack
> variables, just disable KCSAN for kmemleak to avoid annotating anything
> outside Kmemleak just because Kmemleak scans everything.
> 
> Suggested-by: Marco Elver <elver@google.com>
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

* Re: [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr"
  2020-03-03 19:28 ` [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr" Qian Cai
  2020-03-03 20:21     ` Marco Elver
@ 2020-03-11 14:19   ` Catalin Marinas
  1 sibling, 0 replies; 8+ messages in thread
From: Catalin Marinas @ 2020-03-11 14:19 UTC (permalink / raw)
  To: Qian Cai; +Cc: akpm, elver, linux-mm, linux-kernel

On Tue, Mar 03, 2020 at 02:28:36PM -0500, Qian Cai wrote:
> This reverts commit a03184297d546c6531cdd40878f1f50732d3bac9.
> 
> Signed-off-by: Qian Cai <cai@lca.pw>

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

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

end of thread, other threads:[~2020-03-11 14:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 19:28 [PATCH -next 1/2] mm: disable KCSAN for kmemleak Qian Cai
2020-03-03 19:28 ` [PATCH -next 2/2] Revert "mm/kmemleak: annotate various data races obj->ptr" Qian Cai
2020-03-03 20:21   ` Marco Elver
2020-03-03 20:21     ` Marco Elver
2020-03-11 14:19   ` Catalin Marinas
2020-03-03 20:20 ` [PATCH -next 1/2] mm: disable KCSAN for kmemleak Marco Elver
2020-03-03 20:20   ` Marco Elver
2020-03-11 14:18 ` Catalin Marinas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.