From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
"Luck, Tony" <tony.luck@intel.com>,
Ingo Molnar <mingo@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Andrew Morton <akpm@linux-foundation.org>,
Julien Thierry <jthierry@redhat.com>
Subject: Re: [GIT PULL] x86/asm changes for v5.6
Date: Fri, 31 Jan 2020 10:05:18 -0600 [thread overview]
Message-ID: <20200131160518.ou6zadyo5qvkr2xd@treble> (raw)
In-Reply-To: <20200131142727.GB14851@zn.tnic>
On Fri, Jan 31, 2020 at 03:27:27PM +0100, Borislav Petkov wrote:
> + Josh.
>
> On Thu, Jan 30, 2020 at 10:02:54AM -0800, Linus Torvalds wrote:
> > Maybe with the exception that a short conditional jump inside the
> > alternative code itself is fine.
> >
> > Because a branch-over inside the alternative sequence (or a loop -
> > think inline cmpxchg loop or whatever) would be fine, since it's
> > unaffected by code placement.
>
> Perhaps something like the below as a start.
>
> The build becomes really noisy if the error case is hit because aborting
> in handle_group_alt() really messes up objtool processing but that is
> perhaps ok as the idea is to *see* that something's wrong.
[ Adding Julien as an FYI -- not sure how it affects arm64 ]
Boris, I made the check even broader than we discussed on IRC: it
disallows *any* relocations in the alternatives section unless it's the
first instruction in the group and it's a call or a jmp.
Untested, let me know if it works.
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index b6da413bcbd6..382a65363379 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -782,6 +782,20 @@ static int handle_group_alt(struct objtool_file *file,
insn->ignore = orig_insn->ignore_alts;
insn->func = orig_insn->func;
+ /*
+ * The x86 alternatives code adjusts relocation targets only in
+ * the case where the first instruction is either a call or a
+ * jump. Otherwise, relocations aren't supported by the
+ * alternatives code (as there hasn't yet been a need for it).
+ */
+ if (!(insn->offset == special_alt->new_off &&
+ (insn->type == INSN_CALL || insn->type == INSN_JUMP_UNCONDITIONAL)) &&
+ find_rela_by_dest_range(insn->sec, insn->offset, insn->len)) {
+ WARN_FUNC("relocations not allowed in alternatives section",
+ insn->sec, insn->offset);
+ return -1;
+ }
+
if (insn->type != INSN_JUMP_CONDITIONAL &&
insn->type != INSN_JUMP_UNCONDITIONAL)
continue;
@@ -2509,8 +2523,14 @@ int check(const char *_objname, bool orc)
out:
cleanup(&file);
- /* ignore warnings for now until we get all the code cleaned up */
- if (ret || warnings)
- return 0;
+ if (ret < 0) {
+ /*
+ * Fatal error. The binary is corrupt or otherwise broken in
+ * some way, or objtool is badly broken. Fail the kernel
+ * build.
+ */
+ return ret;
+ }
+
return 0;
}
next prev parent reply other threads:[~2020-01-31 16:05 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 16:59 Ingo Molnar
2020-01-28 19:51 ` Linus Torvalds
2020-01-28 20:06 ` Linus Torvalds
2020-01-28 20:14 ` Ingo Molnar
2020-01-28 20:41 ` Luck, Tony
2020-01-28 21:04 ` Linus Torvalds
2020-01-28 22:31 ` Borislav Petkov
2020-01-29 18:00 ` Josh Poimboeuf
2020-01-29 13:26 ` Borislav Petkov
2020-01-29 17:07 ` Luck, Tony
2020-01-29 17:40 ` Linus Torvalds
2020-01-29 18:34 ` Borislav Petkov
2020-01-29 18:56 ` Linus Torvalds
2020-01-30 8:51 ` Borislav Petkov
2020-01-30 15:27 ` Linus Torvalds
2020-01-30 17:39 ` Borislav Petkov
2020-01-30 18:02 ` Linus Torvalds
2020-01-31 14:27 ` Borislav Petkov
2020-01-31 16:05 ` Josh Poimboeuf [this message]
2020-01-29 19:42 ` Luck, Tony
2020-01-30 5:47 ` Damian Tometzki
2020-01-30 7:55 ` Borislav Petkov
2020-01-30 11:10 ` Mike Rapoport
2020-01-30 11:53 ` Borislav Petkov
2020-01-30 11:59 ` Mike Rapoport
2020-01-30 12:06 ` Borislav Petkov
2020-01-30 16:45 ` Damian Tometzki
2020-01-30 17:39 ` Borislav Petkov
2020-01-28 21:15 ` pr-tracker-bot
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=20200131160518.ou6zadyo5qvkr2xd@treble \
--to=jpoimboe@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=bp@alien8.de \
--cc=bp@suse.de \
--cc=jthierry@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--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
all inboxes | Powered by JetHome®