linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrey Konovalov <andreyknvl@gmail.com>
To: "Liam R. Howlett" <Liam.Howlett@oracle.com>,
	"Paul E. McKenney" <paulmck@kernel.org>
Cc: sfr@canb.auug.org.au, linux-next@vger.kernel.org,
	 kasan-dev@googlegroups.com
Subject: Re: [BUG] KASAN "INFO: trying to register non-static key"
Date: Tue, 9 Jan 2024 17:07:54 +0100	[thread overview]
Message-ID: <CA+fCnZewUEv2BMX-D=a+5wosusM-H3tOBpeJe6oyu51mMLXQnA@mail.gmail.com> (raw)
In-Reply-To: <20240109155127.54gsm6r67brdev4l@revolver>

[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]

On Tue, Jan 9, 2024 at 4:51 PM Liam R. Howlett <Liam.Howlett@oracle.com> wrote:
>
> * Paul E. McKenney <paulmck@kernel.org> [240109 09:04]:
> > Hello!
> >
> > I get the splat shown below when running rcutorture on next-20240108
> > (and some less-recent -next versions) on scenarios that run KASAN and
> > that also enable CONFIG_DEBUG_LOCK_ALLOC=y.  I am running gcc 8.5.0.
> >
> > Bisection fingers this commit:
> >
> > a414d4286f34 ("kasan: handle concurrent kasan_record_aux_stack calls")
> >
> > This commit does not appear to be trying to change the annotation
> > required of KASAN users, so I suspect that the commit is at fault.  I am
> > including Liam in case Maple Tree is the bad guy, and should call_rcu()
> > need adjustment, here I am.  ;-)
> >
> > Thoughts?
>
>
> I think this is ma_free_rcu() registering mt_free_rcu() in
> lib/maple_tree.c.
>
> The commit you point to saves and restores the irq state in
> __kasan_record_aux_stack(), but the trace below shows it is called prior
> to irqs being initialized.  This isn't what lockdep is yelling about, so
> what am I missing?  Maybe it will be caught after this issue is
> resolved?

Hm, I see a discrepancy in the KASAN code related to the guilty
commit. I believed it to be harmless, but perhaps it is not.

Paul, could you check if the attached patch fixes the issue for you?
This is rather a quick fix than a proper one, but let's see if this
one works.

Thanks!

[-- Attachment #2: kasan_record_aux_stack-fix.patch --]
[-- Type: text/x-patch, Size: 968 bytes --]

diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index 223af53d4338..0143c1b82004 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -208,10 +208,6 @@ static inline u8 assign_tag(struct kmem_cache *cache,
 void * __must_check __kasan_init_slab_obj(struct kmem_cache *cache,
 						const void *object)
 {
-	/* Initialize per-object metadata if it is present. */
-	if (kasan_requires_meta())
-		kasan_init_object_meta(cache, object);
-
 	/* Tag is ignored in set_tag() without CONFIG_KASAN_SW/HW_TAGS */
 	object = set_tag(object, assign_tag(cache, object, true));
 
@@ -338,6 +334,10 @@ void * __must_check __kasan_slab_alloc(struct kmem_cache *cache,
 	if (is_kfence_address(object))
 		return (void *)object;
 
+	/* Initialize per-object metadata if it is present. */
+	if (kasan_requires_meta())
+		kasan_init_object_meta(cache, object);
+
 	/*
 	 * Generate and assign random tag for tag-based modes.
 	 * Tag is ignored in set_tag() for the generic mode.

  parent reply	other threads:[~2024-01-09 16:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09 14:02 [BUG] KASAN "INFO: trying to register non-static key" Paul E. McKenney
2024-01-09 15:51 ` Liam R. Howlett
2024-01-09 16:07   ` Paul E. McKenney
2024-01-09 16:07   ` Andrey Konovalov [this message]
2024-01-09 17:20     ` Paul E. McKenney
2024-01-09 22:16       ` Andrey Konovalov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CA+fCnZewUEv2BMX-D=a+5wosusM-H3tOBpeJe6oyu51mMLXQnA@mail.gmail.com' \
    --to=andreyknvl@gmail.com \
    --cc=Liam.Howlett@oracle.com \
    --cc=kasan-dev@googlegroups.com \
    --cc=linux-next@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).