From: "tip-bot2 for Josh Poimboeuf" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Randy Dunlap <rdunlap@infradead.org>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Borislav Petkov <bp@suse.de>, Kees Cook <keescook@chromium.org>,
Miroslav Benes <mbenes@suse.cz>,
"Peter Zijlstra (Intel)" <peterz@infradead.org>,
x86 <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [tip: x86/urgent] objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings
Date: Tue, 14 Apr 2020 10:34:03 -0000 [thread overview]
Message-ID: <158686044342.28353.9170954952502687843.tip-bot2@tip-bot2> (raw)
In-Reply-To: <6653ad73c6b59c049211bd7c11ed3809c20ee9f5.1585761021.git.jpoimboe@redhat.com>
The following commit has been merged into the x86/urgent branch of tip:
Commit-ID: bd841d6154f5f41f8a32d3c1b0bc229e326e640a
Gitweb: https://git.kernel.org/tip/bd841d6154f5f41f8a32d3c1b0bc229e326e640a
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Wed, 01 Apr 2020 13:23:25 -05:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Tue, 14 Apr 2020 11:55:09 +02:00
objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings
CONFIG_UBSAN_TRAP causes GCC to emit a UD2 whenever it encounters an
unreachable code path. This includes __builtin_unreachable(). Because
the BUG() macro uses __builtin_unreachable() after it emits its own UD2,
this results in a double UD2. In this case objtool rightfully detects
that the second UD2 is unreachable:
init/main.o: warning: objtool: repair_env_string()+0x1c8: unreachable instruction
We weren't able to figure out a way to get rid of the double UD2s, so
just silence the warning.
Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Miroslav Benes <mbenes@suse.cz>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/6653ad73c6b59c049211bd7c11ed3809c20ee9f5.1585761021.git.jpoimboe@redhat.com
---
tools/objtool/check.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 8dd01f9..4811325 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2364,14 +2364,27 @@ static bool ignore_unreachable_insn(struct instruction *insn)
!strcmp(insn->sec->name, ".altinstr_aux"))
return true;
+ if (!insn->func)
+ return false;
+
+ /*
+ * CONFIG_UBSAN_TRAP inserts a UD2 when it sees
+ * __builtin_unreachable(). The BUG() macro has an unreachable() after
+ * the UD2, which causes GCC's undefined trap logic to emit another UD2
+ * (or occasionally a JMP to UD2).
+ */
+ if (list_prev_entry(insn, list)->dead_end &&
+ (insn->type == INSN_BUG ||
+ (insn->type == INSN_JUMP_UNCONDITIONAL &&
+ insn->jump_dest && insn->jump_dest->type == INSN_BUG)))
+ return true;
+
/*
* Check if this (or a subsequent) instruction is related to
* CONFIG_UBSAN or CONFIG_KASAN.
*
* End the search at 5 instructions to avoid going into the weeds.
*/
- if (!insn->func)
- return false;
for (i = 0; i < 5; i++) {
if (is_kasan_insn(insn) || is_ubsan_insn(insn))
next prev parent reply other threads:[~2020-04-14 10:41 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-01 18:23 [PATCH 0/5] objtool fixes Josh Poimboeuf
2020-04-01 18:23 ` [PATCH 1/5] objtool: Fix CONFIG_UBSAN_TRAP unreachable warnings Josh Poimboeuf
2020-04-02 7:30 ` Kees Cook
2020-04-14 10:34 ` tip-bot2 for Josh Poimboeuf [this message]
2020-04-01 18:23 ` [PATCH 2/5] objtool: Support Clang non-section symbols in ORC dump Josh Poimboeuf
2020-04-14 10:34 ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2020-04-01 18:23 ` [PATCH 3/5] objtool: Support Clang non-section symbols in ORC generation Josh Poimboeuf
2020-04-01 18:49 ` Peter Zijlstra
2020-04-01 19:05 ` Josh Poimboeuf
2020-04-01 19:08 ` Josh Poimboeuf
2020-04-03 8:58 ` Miroslav Benes
2020-04-03 14:58 ` Josh Poimboeuf
2020-04-14 10:34 ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2020-04-01 18:23 ` [PATCH 4/5] objtool: Fix switch table detection in .text.unlikely Josh Poimboeuf
2020-04-14 10:34 ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2020-04-01 18:23 ` [PATCH 5/5] objtool: Make BP scratch register warning more robust Josh Poimboeuf
2020-04-14 10:34 ` [tip: x86/urgent] " tip-bot2 for Josh Poimboeuf
2020-04-02 14:28 ` [PATCH 0/5] objtool fixes Peter Zijlstra
2020-04-03 9:00 ` Miroslav Benes
2020-04-09 13:53 ` Josh Poimboeuf
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=158686044342.28353.9170954952502687843.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@suse.de \
--cc=jpoimboe@redhat.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=peterz@infradead.org \
--cc=rdunlap@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®