diff mbox series

[mm] kasan: initialize read-write lock in stack ring

Message ID 576182d194e27531e8090bad809e4136953895f4.1663700262.git.andreyknvl@google.com (mailing list archive)
State New
Headers show
Series [mm] kasan: initialize read-write lock in stack ring | expand

Commit Message

andrey.konovalov@linux.dev Sept. 20, 2022, 6:58 p.m. UTC
From: Andrey Konovalov <andreyknvl@google.com>

Use __RW_LOCK_UNLOCKED to initialize stack_ring.lock.

Reported-by: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrey Konovalov <andreyknvl@google.com>

---

Andrew, could you please fold this patch into:
"kasan: implement stack ring for tag-based modes".
---
 mm/kasan/tags.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Marco Elver Sept. 20, 2022, 7:09 p.m. UTC | #1
On Tue, 20 Sept 2022 at 20:58, <andrey.konovalov@linux.dev> wrote:
>
> From: Andrey Konovalov <andreyknvl@google.com>
>
> Use __RW_LOCK_UNLOCKED to initialize stack_ring.lock.
>
> Reported-by: Yu Zhao <yuzhao@google.com>
> Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
>
> ---
>
> Andrew, could you please fold this patch into:
> "kasan: implement stack ring for tag-based modes".
> ---
>  mm/kasan/tags.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c
> index 9d867cae1b7b..67a222586846 100644
> --- a/mm/kasan/tags.c
> +++ b/mm/kasan/tags.c
> @@ -36,7 +36,9 @@ DEFINE_STATIC_KEY_TRUE(kasan_flag_stacktrace);
>  /* Non-zero, as initial pointer values are 0. */
>  #define STACK_RING_BUSY_PTR ((void *)1)
>
> -struct kasan_stack_ring stack_ring;
> +struct kasan_stack_ring stack_ring = {
> +       .lock = __RW_LOCK_UNLOCKED(stack_ring.lock)
> +};

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

>  /* kasan.stacktrace=off/on */
>  static int __init early_kasan_flag_stacktrace(char *arg)
> --
> 2.25.1
>
Yu Zhao Sept. 20, 2022, 7:13 p.m. UTC | #2
On Tue, Sep 20, 2022 at 1:10 PM Marco Elver <elver@google.com> wrote:
>
> On Tue, 20 Sept 2022 at 20:58, <andrey.konovalov@linux.dev> wrote:
> >
> > From: Andrey Konovalov <andreyknvl@google.com>
> >
> > Use __RW_LOCK_UNLOCKED to initialize stack_ring.lock.
> >
> > Reported-by: Yu Zhao <yuzhao@google.com>
> > Signed-off-by: Andrey Konovalov <andreyknvl@google.com>
> >
> > ---
> >
> > Andrew, could you please fold this patch into:
> > "kasan: implement stack ring for tag-based modes".
> > ---
> >  mm/kasan/tags.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c
> > index 9d867cae1b7b..67a222586846 100644
> > --- a/mm/kasan/tags.c
> > +++ b/mm/kasan/tags.c
> > @@ -36,7 +36,9 @@ DEFINE_STATIC_KEY_TRUE(kasan_flag_stacktrace);
> >  /* Non-zero, as initial pointer values are 0. */
> >  #define STACK_RING_BUSY_PTR ((void *)1)
> >
> > -struct kasan_stack_ring stack_ring;
> > +struct kasan_stack_ring stack_ring = {
> > +       .lock = __RW_LOCK_UNLOCKED(stack_ring.lock)
> > +};
>
> Reviewed-by: Marco Elver <elver@google.com>

Tested-by: Yu Zhao <yuzhao@google.com>
diff mbox series

Patch

diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c
index 9d867cae1b7b..67a222586846 100644
--- a/mm/kasan/tags.c
+++ b/mm/kasan/tags.c
@@ -36,7 +36,9 @@  DEFINE_STATIC_KEY_TRUE(kasan_flag_stacktrace);
 /* Non-zero, as initial pointer values are 0. */
 #define STACK_RING_BUSY_PTR ((void *)1)
 
-struct kasan_stack_ring stack_ring;
+struct kasan_stack_ring stack_ring = {
+	.lock = __RW_LOCK_UNLOCKED(stack_ring.lock)
+};
 
 /* kasan.stacktrace=off/on */
 static int __init early_kasan_flag_stacktrace(char *arg)