From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
Miroslav Benes <mbenes@suse.cz>
Subject: Re: [PATCH 10/18] objtool: Extricate ibt from stack validation
Date: Thu, 14 Apr 2022 08:44:49 -0700 [thread overview]
Message-ID: <20220414154449.5moa7xsczwybbqhd@treble> (raw)
In-Reply-To: <YlfS7twQVCHGgtCV@hirez.programming.kicks-ass.net>
On Thu, Apr 14, 2022 at 09:53:18AM +0200, Peter Zijlstra wrote:
> On Wed, Apr 13, 2022 at 04:19:45PM -0700, Josh Poimboeuf wrote:
> > Extricate ibt from validate_branch() in preparation for making stack
> > validation optional.
>
> It does a bit more..
Indeed.
> > - /* already done in validate_branch() */
> > - if (sec->sh.sh_flags & SHF_EXECINSTR)
> > - continue;
> >
> > - if (!sec->reloc)
> > continue;
> >
> > - if (!strncmp(sec->name, ".orc", 4))
> > - continue;
> >
> > - if (!strncmp(sec->name, ".discard", 8))
> > continue;
> >
> > - if (!strncmp(sec->name, ".debug", 6))
> > continue;
> >
> > - if (!strcmp(sec->name, "_error_injection_whitelist"))
> > continue;
> >
> > - if (!strcmp(sec->name, "_kprobe_blacklist"))
> > continue;
> >
> > - is_data = strstr(sec->name, ".data") || strstr(sec->name, ".rodata");
> >
> > - list_for_each_entry(reloc, &sec->reloc->reloc_list, list) {
> > - struct instruction *dest;
> >
> > - dest = validate_ibt_reloc(file, reloc);
> > - if (is_data && dest && !dest->noendbr)
> > - warn_noendbr("data ", sec, reloc->offset, dest);
> > - }
>
> So this iterates all sections and excludes a bunch, and only reports
> fail for .data/.rodata.
Oops.
> > +static int validate_ibt(struct objtool_file *file)
> > +{
> > + struct section *sec;
> > + struct reloc *reloc;
> > + struct instruction *insn;
> > + int warnings = 0;
> > +
> > + for_each_insn(file, insn)
> > + warnings += validate_ibt_insn(file, insn);
>
> So I specifically didn't do this because I wanted to reduce the amount
> of loops we do over those instructions. But yeah, if you really want to
> allow --ibt without --stack-validate (but why?) then I suppose so.
>
> Esp. for the vmlinux.o case, iterating all insn can quickly add up to
> significant time.
I didn't look at the performance, but if it's a problem then we can
eventually look at combining several of the for_each_insn() features
into a single loop: retpolines, ibt, reachability check, maybe even some
of decode_sections().
>
> > + for_each_sec(file, sec) {
> > +
> > + if (!strstr(sec->name, ".data") && !strstr(sec->name, ".rodata"))
> > + continue;
>
> But this only iterates .data/.rodata.
>
> That's not the same, specifically, it'll not iterate stuff like ksymtab
> that contains the EXPORT_SYMBOL* crud. The result being that we can now
> seal EXPORT'ed symbols, which will make modules really sad.
>
> There's also the .initcall sections, sealing initcalls typcally ends really
> badly.
>
> And there might be a few others I forgot about.
Ok. That was subtle, it needs a comment or two. I had the distinct
feeling I was introducing a bug, then I got distracted ;-)
Doesn't the compiler give those special cases ENDBR anyway? Just
wondering why we avoid the warning for those.
--
Josh
next prev parent reply other threads:[~2022-04-14 16:07 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 23:19 [PATCH 00/18] objtool: Interface overhaul Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 01/18] objtool: Enable unreachable warnings for CLANG LTO Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 02/18] objtool: Support data symbol printing Josh Poimboeuf
2022-04-14 7:05 ` Peter Zijlstra
2022-04-14 15:21 ` Josh Poimboeuf
2022-04-14 15:31 ` Peter Zijlstra
2022-04-14 15:38 ` Josh Poimboeuf
2022-04-14 16:36 ` Peter Zijlstra
2022-04-14 17:01 ` Josh Poimboeuf
2022-04-14 17:21 ` Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 03/18] objtool: Add sec+offset to warnings Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 04/18] objtool: Print data address for "!ENDBR" data warnings Josh Poimboeuf
2022-04-14 7:36 ` Peter Zijlstra
2022-04-13 23:19 ` [PATCH 05/18] objtool: Use offstr() to print address of missing ENDBR Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 06/18] libsubcmd: Fix OPTION_GROUP sorting Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 07/18] objtool: Reorganize cmdline options Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 08/18] objtool: Ditch subcommands Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 09/18] objtool: Add stack validation cmdline option Josh Poimboeuf
2022-04-14 8:43 ` Peter Zijlstra
2022-04-14 15:52 ` Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 10/18] objtool: Extricate ibt from stack validation Josh Poimboeuf
2022-04-14 7:53 ` Peter Zijlstra
2022-04-14 15:44 ` Josh Poimboeuf [this message]
2022-04-14 16:38 ` Peter Zijlstra
2022-04-14 17:05 ` Josh Poimboeuf
2022-04-14 18:25 ` Josh Poimboeuf
2022-04-14 19:01 ` Peter Zijlstra
2022-04-14 19:07 ` Josh Poimboeuf
2022-04-14 18:49 ` Peter Zijlstra
2022-04-13 23:19 ` [PATCH 11/18] objtool: Add CONFIG_OBJTOOL Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 12/18] objtool: Make stack validation frame-pointer-specific Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 13/18] objtool: Add static call cmdline option Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 14/18] objtool: Add toolchain hacks " Josh Poimboeuf
2022-04-14 8:09 ` Peter Zijlstra
2022-04-14 15:49 ` Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 15/18] objtool: Rename "VMLINUX_VALIDATION" -> "NOINSTR_VALIDATION" Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 16/18] objtool: Add HAVE_NOINSTR_VALIDATION Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 17/18] objtool: Remove --lto and --vmlinux Josh Poimboeuf
2022-04-14 8:13 ` Peter Zijlstra
2022-04-15 2:18 ` Josh Poimboeuf
2022-04-13 23:19 ` [PATCH 18/18] objtool: Update documentation 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=20220414154449.5moa7xsczwybbqhd@treble \
--to=jpoimboe@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mbenes@suse.cz \
--cc=peterz@infradead.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
all inboxes | Powered by JetHome®