From: "tip-bot2 for Josh Poimboeuf" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: Nick Desaulniers <ndesaulniers@google.com>,
Josh Poimboeuf <jpoimboe@redhat.com>,
Borislav Petkov <bp@suse.de>,
Nathan Chancellor <natechancellor@gmail.com>,
x86 <x86@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Subject: [tip: core/objtool] objtool: Fix clang switch table edge case
Date: Fri, 21 Feb 2020 09:50:52 -0000 [thread overview]
Message-ID: <158227865267.28353.1809834371587369139.tip-bot2@tip-bot2> (raw)
In-Reply-To: <263f6aae46d33da0b86d7030ced878cb5cab1788.1581997059.git.jpoimboe@redhat.com>
The following commit has been merged into the core/objtool branch of tip:
Commit-ID: 113d4bc9048336ba7c3d2ad972dbad4aef6e148a
Gitweb: https://git.kernel.org/tip/113d4bc9048336ba7c3d2ad972dbad4aef6e148a
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Mon, 17 Feb 2020 21:41:53 -06:00
Committer: Borislav Petkov <bp@suse.de>
CommitterDate: Fri, 21 Feb 2020 10:12:52 +01:00
objtool: Fix clang switch table edge case
Clang has the ability to create a switch table which is not a jump
table, but is rather a table of string pointers. This confuses objtool,
because it sees the relocations for the string pointers and assumes
they're part of a jump table:
drivers/ata/sata_dwc_460ex.o: warning: objtool: sata_dwc_bmdma_start_by_tag()+0x3a2: can't find switch jump table
net/ceph/messenger.o: warning: objtool: ceph_con_workfn()+0x47c: can't find switch jump table
Make objtool's find_jump_table() smart enough to distinguish between a
switch jump table (which has relocations to text addresses in the same
function as the original instruction) and other anonymous rodata (which
may have relocations to elsewhere).
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nathan Chancellor <natechancellor@gmail.com>
Link: https://github.com/ClangBuiltLinux/linux/issues/485
Link: https://lkml.kernel.org/r/263f6aae46d33da0b86d7030ced878cb5cab1788.1581997059.git.jpoimboe@redhat.com
---
tools/objtool/check.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index b038de2..4d6e283 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1025,7 +1025,7 @@ static struct rela *find_jump_table(struct objtool_file *file,
struct instruction *insn)
{
struct rela *text_rela, *table_rela;
- struct instruction *orig_insn = insn;
+ struct instruction *dest_insn, *orig_insn = insn;
struct section *table_sec;
unsigned long table_offset;
@@ -1077,10 +1077,17 @@ static struct rela *find_jump_table(struct objtool_file *file,
strcmp(table_sec->name, C_JUMP_TABLE_SECTION))
continue;
- /* Each table entry has a rela associated with it. */
+ /*
+ * Each table entry has a rela associated with it. The rela
+ * should reference text in the same function as the original
+ * instruction.
+ */
table_rela = find_rela_by_dest(table_sec, table_offset);
if (!table_rela)
continue;
+ dest_insn = find_insn(file, table_rela->sym->sec, table_rela->addend);
+ if (!dest_insn || !dest_insn->func || dest_insn->func->pfunc != func)
+ continue;
/*
* Use of RIP-relative switch jumps is quite rare, and
next prev parent reply other threads:[~2020-02-21 9:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-18 3:41 [PATCH 0/2] objtool: clang-related fixes Josh Poimboeuf
2020-02-18 3:41 ` [PATCH 1/2] objtool: Fix clang switch table edge case Josh Poimboeuf
2020-02-18 19:57 ` Nathan Chancellor
2020-02-21 9:50 ` tip-bot2 for Josh Poimboeuf [this message]
2020-02-18 3:41 ` [PATCH 2/2] objtool: Improve call destination function detection Josh Poimboeuf
2020-02-18 18:13 ` Nick Desaulniers
2020-02-18 19:58 ` Nathan Chancellor
2020-02-21 9:50 ` [tip: core/objtool] " tip-bot2 for Josh Poimboeuf
2020-02-20 19:06 ` [PATCH 0/2] objtool: clang-related fixes Nick Desaulniers
2020-02-20 19:27 ` Borislav Petkov
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=158227865267.28353.1809834371587369139.tip-bot2@tip-bot2 \
--to=tip-bot2@linutronix.de \
--cc=bp@suse.de \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--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;
as well as URLs for NNTP newsgroup(s).