From: Alexander Potapenko <glider@google.com>
To: glider@google.com
Cc: elver@google.com, dvyukov@google.com,
dave.hansen@linux.intel.com, peterz@infradead.org,
akpm@linux-foundation.org, x86@kernel.org,
linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>
Subject: [PATCH 3/3] x86/traps: fix an objtool warning in handle_bug()
Date: Fri, 21 Jun 2024 11:49:01 +0200 [thread overview]
Message-ID: <20240621094901.1360454-3-glider@google.com> (raw)
In-Reply-To: <20240621094901.1360454-1-glider@google.com>
Because handle_bug() is a noinstr function, call to
kmsan_unpoison_entry_regs() should be happening within the
instrumentation_begin()/instrumentation_end() region.
Fortunately, the same noinstr annotation lets us dereference @regs
in handle_bug() without unpoisoning them, so we don't have to move the
`is_valid_bugaddr(regs->ip)` check below instrumentation_begin().
Reported-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Link: https://groups.google.com/g/kasan-dev/c/ZBiGzZL36-I/m/WtNuKqP9EQAJ
Signed-off-by: Alexander Potapenko <glider@google.com>
---
arch/x86/kernel/traps.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
index 4fa0b17e5043a..e8f330d9ba5d4 100644
--- a/arch/x86/kernel/traps.c
+++ b/arch/x86/kernel/traps.c
@@ -217,12 +217,6 @@ static noinstr bool handle_bug(struct pt_regs *regs)
{
bool handled = false;
- /*
- * Normally @regs are unpoisoned by irqentry_enter(), but handle_bug()
- * is a rare case that uses @regs without passing them to
- * irqentry_enter().
- */
- kmsan_unpoison_entry_regs(regs);
if (!is_valid_bugaddr(regs->ip))
return handled;
@@ -230,6 +224,15 @@ static noinstr bool handle_bug(struct pt_regs *regs)
* All lies, just get the WARN/BUG out.
*/
instrumentation_begin();
+ /*
+ * Normally @regs are unpoisoned by irqentry_enter(), but handle_bug()
+ * is a rare case that uses @regs without passing them to
+ * irqentry_enter().
+ * Unpoisoning of @regs should be done before the first access to it,
+ * but because this is a noinstr function it is fine to postpone
+ * unpoisoning until the call of instrumentation_begin().
+ */
+ kmsan_unpoison_entry_regs(regs);
/*
* Since we're emulating a CALL with exceptions, restore the interrupt
* state to what it was at the exception site.
--
2.45.2.741.gdbec12cfda-goog
next prev parent reply other threads:[~2024-06-21 9:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 9:48 [PATCH 1/3] x86: mm: disable KMSAN instrumentation for physaddr.c Alexander Potapenko
2024-06-21 9:49 ` [PATCH 2/3] lib/Kconfig.debug: disable LOCK_DEBUGGING_SUPPORT under KMSAN Alexander Potapenko
2024-06-21 15:02 ` Kirill A . Shutemov
2024-06-21 16:16 ` Dave Hansen
2024-06-21 16:23 ` Dave Hansen
2024-06-25 18:51 ` Boqun Feng
2024-06-25 19:06 ` Paul E. McKenney
2024-06-25 19:37 ` Boqun Feng
2024-06-26 8:35 ` Alexander Potapenko
2024-06-21 9:49 ` Alexander Potapenko [this message]
2024-06-21 15:09 ` [PATCH 3/3] x86/traps: fix an objtool warning in handle_bug() Kirill A . Shutemov
2024-06-21 14:57 ` [PATCH 1/3] x86: mm: disable KMSAN instrumentation for physaddr.c Kirill A . Shutemov
2024-06-21 16:40 ` Dave Hansen
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=20240621094901.1360454-3-glider@google.com \
--to=glider@google.com \
--cc=akpm@linux-foundation.org \
--cc=dave.hansen@linux.intel.com \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/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 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.