From: tip-bot for Josh Poimboeuf <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jpoimboe@redhat.com, peterz@infradead.org, tglx@linutronix.de,
torvalds@linux-foundation.org, hpa@zytor.com, efault@gmx.de,
mingo@kernel.org, linux-kernel@vger.kernel.org
Subject: [tip:core/urgent] objtool: Fix sibling call detection logic
Date: Sat, 8 Jul 2017 01:33:56 -0700 [thread overview]
Message-ID: <tip-4855022a52262411ce38c93dec4cb1470705c0a0@git.kernel.org> (raw)
In-Reply-To: <96cc8ecbcdd8cb29ddd783817b4af918a6a171b0.1499437107.git.jpoimboe@redhat.com>
Commit-ID: 4855022a52262411ce38c93dec4cb1470705c0a0
Gitweb: http://git.kernel.org/tip/4855022a52262411ce38c93dec4cb1470705c0a0
Author: Josh Poimboeuf <jpoimboe@redhat.com>
AuthorDate: Fri, 7 Jul 2017 09:19:42 -0500
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 8 Jul 2017 10:29:48 +0200
objtool: Fix sibling call detection logic
With some configs, objtool reports the following warning:
arch/x86/kernel/ftrace.o: warning: objtool: ftrace_modify_code_direct()+0x2d: sibling call from callable instruction with modified stack frame
The instruction it's complaining about isn't actually a sibling call.
It's just a normal jump to an address inside the function. Objtool
thought it was a sibling call because the instruction's jump_dest wasn't
initialized because the function was supposed to be ignored due to its
use of sync_core().
Objtool ended up validating the function instead of ignoring it because
it didn't properly recognize a sibling call to the function. So fix the
sibling call logic. Also add a warning to catch ignored functions being
validated so we'll get a more useful error message next time.
Reported-by: Mike Galbraith <efault@gmx.de>
Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/96cc8ecbcdd8cb29ddd783817b4af918a6a171b0.1499437107.git.jpoimboe@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
tools/objtool/check.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index fea2221..2c6d748 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1371,6 +1371,12 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
func = insn->func;
+ if (func && insn->ignore) {
+ WARN_FUNC("BUG: why am I validating an ignored function?",
+ sec, insn->offset);
+ return -1;
+ }
+
if (insn->visited) {
if (!!insn_state_match(insn, &state))
return 1;
@@ -1426,16 +1432,19 @@ static int validate_branch(struct objtool_file *file, struct instruction *first,
case INSN_JUMP_CONDITIONAL:
case INSN_JUMP_UNCONDITIONAL:
- if (insn->jump_dest) {
+ if (insn->jump_dest &&
+ (!func || !insn->jump_dest->func ||
+ func == insn->jump_dest->func)) {
ret = validate_branch(file, insn->jump_dest,
state);
if (ret)
return 1;
+
} else if (func && has_modified_stack_frame(&state)) {
WARN_FUNC("sibling call from callable instruction with modified stack frame",
sec, insn->offset);
return 1;
- } /* else it's a sibling call */
+ }
if (insn->type == INSN_JUMP_UNCONDITIONAL)
return 0;
prev parent reply other threads:[~2017-07-08 8:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-07 14:19 [PATCH] objtool: Fix sibling call detection logic Josh Poimboeuf
2017-07-08 8:33 ` tip-bot for Josh Poimboeuf [this message]
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=tip-4855022a52262411ce38c93dec4cb1470705c0a0@git.kernel.org \
--to=tipbot@zytor.com \
--cc=efault@gmx.de \
--cc=hpa@zytor.com \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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).