[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <160070707105.15536.14094674309505985856.tip-bot2@tip-bot2>
Date: Mon, 21 Sep 2020 16:51:11 -0000
From: "tip-bot2 for Ilie Halip" <tip-bot2@...utronix.de>
To: linux-tip-commits@...r.kernel.org
Cc: Nick Desaulniers <ndesaulniers@...gle.com>,
Rong Chen <rong.a.chen@...el.com>,
Marco Elver <elver@...gle.com>,
Philip Li <philip.li@...el.com>,
Borislav Petkov <bp@...en8.de>, kasan-dev@...glegroups.com,
x86@...nel.org, clang-built-linux@...glegroups.com,
kbuild test robot <lkp@...el.com>,
Ilie Halip <ilie.halip@...il.com>,
Sedat Dilek <sedat.dilek@...il.com>,
Josh Poimboeuf <jpoimboe@...hat.com>,
LKML <linux-kernel@...r.kernel.org>
Subject: [tip: objtool/core] objtool: Ignore unreachable trap after call to
noreturn functions
The following commit has been merged into the objtool/core branch of tip:
Commit-ID: 14db1f0a93331d0958e90da522c429ff0890d2d6
Gitweb: https://git.kernel.org/tip/14db1f0a93331d0958e90da522c429ff0890d2d6
Author: Ilie Halip <ilie.halip@...il.com>
AuthorDate: Sat, 19 Sep 2020 09:41:18 +03:00
Committer: Josh Poimboeuf <jpoimboe@...hat.com>
CommitterDate: Mon, 21 Sep 2020 10:20:10 -05:00
objtool: Ignore unreachable trap after call to noreturn functions
With CONFIG_UBSAN_TRAP enabled, the compiler may insert a trap
instruction after a call to a noreturn function. In this case, objtool
warns that the UD2 instruction is unreachable.
This is a behavior seen with Clang, from the oldest version capable of
building the mainline x64_64 kernel (9.0), to the latest experimental
version (12.0).
Objtool silences similar warnings (trap after dead end instructions), so
so expand that check to include dead end functions.
Cc: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Rong Chen <rong.a.chen@...el.com>
Cc: Marco Elver <elver@...gle.com>
Cc: Philip Li <philip.li@...el.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: kasan-dev@...glegroups.com
Cc: x86@...nel.org
Cc: clang-built-linux@...glegroups.com
BugLink: https://github.com/ClangBuiltLinux/linux/issues/1148
Link: https://lore.kernel.org/lkml/CAKwvOdmptEpi8fiOyWUo=AiZJiX+Z+VHJOM2buLPrWsMTwLnyw@mail.gmail.com
Suggested-by: Nick Desaulniers <ndesaulniers@...gle.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@...gle.com>
Tested-by: Nick Desaulniers <ndesaulniers@...gle.com>
Reported-by: kbuild test robot <lkp@...el.com>
Signed-off-by: Ilie Halip <ilie.halip@...il.com>
Tested-by: Sedat Dilek <sedat.dilek@...il.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@...hat.com>
---
tools/objtool/check.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index a4796e3..2df9f76 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -2638,9 +2638,10 @@ static bool is_ubsan_insn(struct instruction *insn)
"__ubsan_handle_builtin_unreachable"));
}
-static bool ignore_unreachable_insn(struct instruction *insn)
+static bool ignore_unreachable_insn(struct objtool_file *file, struct instruction *insn)
{
int i;
+ struct instruction *prev_insn;
if (insn->ignore || insn->type == INSN_NOP)
return true;
@@ -2668,8 +2669,11 @@ static bool ignore_unreachable_insn(struct instruction *insn)
* __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).
+ *
+ * It may also insert a UD2 after calling a __noreturn function.
*/
- if (list_prev_entry(insn, list)->dead_end &&
+ prev_insn = list_prev_entry(insn, list);
+ if ((prev_insn->dead_end || dead_end_function(file, prev_insn->call_dest)) &&
(insn->type == INSN_BUG ||
(insn->type == INSN_JUMP_UNCONDITIONAL &&
insn->jump_dest && insn->jump_dest->type == INSN_BUG)))
@@ -2796,7 +2800,7 @@ static int validate_reachable_instructions(struct objtool_file *file)
return 0;
for_each_insn(file, insn) {
- if (insn->visited || ignore_unreachable_insn(insn))
+ if (insn->visited || ignore_unreachable_insn(file, insn))
continue;
WARN_FUNC("unreachable instruction", insn->sec, insn->offset);
Powered by blists - more mailing lists