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

0 views
Skip to first unread message

andrey.k...@linux.dev

unread,
Sep 20, 2022, 2:58:13 PMSep 20
to Andrew Morton, Andrey Konovalov, Marco Elver, Alexander Potapenko, Dmitry Vyukov, Andrey Ryabinin, kasa...@googlegroups.com, linu...@kvack.org, Yu Zhao, linux-...@vger.kernel.org, Andrey Konovalov
From: Andrey Konovalov <andre...@google.com>

Use __RW_LOCK_UNLOCKED to initialize stack_ring.lock.

Reported-by: Yu Zhao <yuz...@google.com>
Signed-off-by: Andrey Konovalov <andre...@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)
+};

/* kasan.stacktrace=off/on */
static int __init early_kasan_flag_stacktrace(char *arg)
--
2.25.1

Marco Elver

unread,
Sep 20, 2022, 3:10:21 PMSep 20
to andrey.k...@linux.dev, Andrew Morton, Andrey Konovalov, Alexander Potapenko, Dmitry Vyukov, Andrey Ryabinin, kasa...@googlegroups.com, linu...@kvack.org, Yu Zhao, linux-...@vger.kernel.org, Andrey Konovalov
On Tue, 20 Sept 2022 at 20:58, <andrey.k...@linux.dev> wrote:
>
> From: Andrey Konovalov <andre...@google.com>
>
> Use __RW_LOCK_UNLOCKED to initialize stack_ring.lock.
>
> Reported-by: Yu Zhao <yuz...@google.com>
> Signed-off-by: Andrey Konovalov <andre...@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 <el...@google.com>

Yu Zhao

unread,
Sep 20, 2022, 3:14:21 PMSep 20
to Marco Elver, andrey.k...@linux.dev, Andrew Morton, Andrey Konovalov, Alexander Potapenko, Dmitry Vyukov, Andrey Ryabinin, kasa...@googlegroups.com, linu...@kvack.org, linux-...@vger.kernel.org, Andrey Konovalov
On Tue, Sep 20, 2022 at 1:10 PM Marco Elver <el...@google.com> wrote:
>
> On Tue, 20 Sept 2022 at 20:58, <andrey.k...@linux.dev> wrote:
> >
> > From: Andrey Konovalov <andre...@google.com>
> >
> > Use __RW_LOCK_UNLOCKED to initialize stack_ring.lock.
> >
> > Reported-by: Yu Zhao <yuz...@google.com>
> > Signed-off-by: Andrey Konovalov <andre...@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 <el...@google.com>

Tested-by: Yu Zhao <yuz...@google.com>
Reply all
Reply to author
Forward
0 new messages