From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] objtool: Fix SLS checks
Date: Wed, 4 May 2022 09:26:47 +0200 [thread overview]
Message-ID: <YnIqt4aOooAvlja4@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <20220503211510.ytdv5l4l2zwjdwg7@treble>
On Tue, May 03, 2022 at 02:15:10PM -0700, Josh Poimboeuf wrote:
> On Mon, May 02, 2022 at 10:17:39PM +0200, Peter Zijlstra wrote:
> > > +++ b/tools/objtool/check.c
> > > @@ -3842,9 +3842,6 @@ static int validate_sls(struct objtool_file *file)
> > > for_each_insn(file, insn) {
> > > next_insn = next_insn_same_sec(file, insn);
> > >
> > > - if (insn->retpoline_safe)
> > > - continue;
> > > -
> > > switch (insn->type) {
> > > case INSN_RETURN:
> > > if (!next_insn || next_insn->type != INSN_TRAP) {
> >
> > Yes, agreed. But perhaps with something like this on top?
>
> Yup, I missed those... Looks good. Just one comment:
>
> > +++ b/arch/x86/kernel/alternative.c
> > @@ -452,6 +452,17 @@ static int patch_retpoline(void *addr, struct insn *insn, u8 *bytes)
> > return ret;
> > i += ret;
> >
> > +#ifdef CONFIG_SLS
> > + /*
> > + * Ideally this would be unconditional, except in case of
> > + * RETPOLINE_LFENCE we don't have sufficient space. Additionally,
> > + * -mharden-sls=all should be extended to emit INT3 after
> > + * direct jumps too, which will then cover that case.
> > + */
>
> I don't quite follow this 2nd sentence and how it's related here, since
> this function doesn't actually deal with direct jumps.
Ah, my bad. Also, this wrong.
I suppose this wants to be something like:
if (i < insn->length && op == JMP32_INSN_OPCODE)
bytes[i++] = INT3_INSN_OPCODE;
So this *can* be a jump, but typically won't be I suppose.
> Speaking of, I guess we'll eventually need to hack this SLS mess into
> jump labels :-/
Urgh... can't we reason that the straight line case is actually expected
to run with the given register state anyway and ignore this?
next prev parent reply other threads:[~2022-05-04 7:27 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-30 10:50 [PATCH] objtool: Fix SLS checks Peter Zijlstra
2022-05-02 18:15 ` Josh Poimboeuf
2022-05-02 20:01 ` Peter Zijlstra
2022-05-02 20:09 ` Josh Poimboeuf
2022-05-02 20:17 ` Peter Zijlstra
2022-05-03 21:15 ` Josh Poimboeuf
2022-05-04 7:26 ` Peter Zijlstra [this message]
2022-05-05 21:03 ` 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=YnIqt4aOooAvlja4@hirez.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.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