From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
Michal Marek <mmarek@suse.cz>,
Peter Zijlstra <peterz@infradead.org>,
Andy Lutomirski <luto@kernel.org>, Borislav Petkov <bp@alien8.de>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andi Kleen <andi@firstfloor.org>, Pedro Alves <palves@redhat.com>,
X86 ML <x86@kernel.org>,
live-patching@vger.kernel.org,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 2/4] x86/stackvalidate: Compile-time stack validation
Date: Tue, 7 Jul 2015 18:48:37 -0500 [thread overview]
Message-ID: <20150707234837.GE31294@treble.redhat.com> (raw)
In-Reply-To: <CALCETrXroaTXzUzvdTujNn44adTf0J8YS8bG3C_rR-HYXbv2ow@mail.gmail.com>
On Tue, Jul 07, 2015 at 04:35:17PM -0700, Andy Lutomirski wrote:
> On Tue, Jul 7, 2015 at 4:29 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > On Tue, Jul 07, 2015 at 03:57:14PM -0700, Andy Lutomirski wrote:
> >> On Tue, Jul 7, 2015 at 7:54 AM, Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> >> >
> >> > It currently only supports x86_64. I tried to make the code generic so
> >> > that support for other architectures can hopefully be plugged in
> >> > relatively easily.
> >> >
> >> > Currently with my Fedora config it's reporting over 1400 warnings, but
> >> > most of them are duplicates. The warnings affect 37 .c files and 18 .S
> >> > files. The C file warnings are generally due to inline assembly, which
> >> > doesn't seem to play nice with frame pointers.
> >>
> >> This issue might be worth bringing up on the gcc and binutils lists.
> >> If we need better toolchain support, let's ask for it.
> >
> > I think we found a good solution for this. See my update at:
> >
> > https://lkml.kernel.org/r/20150707223519.GA31294@treble.redhat.com
>
> Does that force frame pointer generation? If so, then once we have a
> real kernel unwinder, we might want a non-frame-pointer-forcing
> version for better code generation. (That can wait, of course.)
I strongly doubt it would force frame pointer generation if
-fomit-frame-pointer is set. But I'll verify :-)
> >> > +
> >> > + This is a context switch instruction like sysenter or sysret. Such
> >> > + instructions aren't allowed in a callable function, and are most
> >> > + likely part of kernel entry code.
> >> > +
> >> > + If the instruction isn't actually in a callable function, change
> >> > + ENDPROC to END.
> >> > +
> >> > +
> >> > +6. stackvalidate: asm_file.o: func()+0x26: jump to outside file from callable function
> >> > + or
> >> > + stackvalidate: asm_file.o: func()+0xd9: jump to dynamic address from callable function
> >> > +
> >> > + These are constraints imposed by stackvalidate so that it can
> >> > + properly analyze all jump targets. Dynamic jump targets and jumps to
> >> > + code in other object files aren't allowed.
> >>
> >> Does this not trigger due to optimized sibling calls to different files?
> >
> > This is a great point. With CONFIG_FRAME_POINTER it's not a problem,
> > because it adds -fno-optimize-sibling-calls.
> >
> > Without it, I think stackvalidate would spit out a ton of "jump to
> > outside file" warnings.
> >
> > I haven't yet looked at the details of how exactly sibling calls work.
> > I'd assume they're disabled because they break frame pointers somehow.
> > Any idea if they'd also break DWARF CFI stack traces?
>
> They'll certainly prevent unwinding from finding the pre-optimization
> caller, but the rest of unwinding should work. I don't know why we
> turn it off, though.
>
> You might want special-case jump-out-of-translation-unit to be okay if
> the stack frame is in its initial state. That is:
>
> func:
> jmp elsewhere
>
> could be considered okay, as could:
>
> func:
> push %rax
> pop %rax
> jmp elsewhere
>
> and similar.
Ah, nice idea. That might cover all the cases. I'll try it.
>
> >
> > I probably need to do some digging there. If sibling calls don't break
> > CFI stack traces and we end up needing them, stackvalidate might need to
> > analyze the entire kernel image at once instead of its current per-.o
> > checking.
> >
> > Anyway, thanks a bunch for all your insightful feedback Andy!
> >
>
> I'm just pretending to be insightful :)
Insightful or not, your comments have been very helpful!
--
Josh
next prev parent reply other threads:[~2015-07-07 23:48 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 14:54 [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 1/4] x86/asm: Frame pointer macro cleanup Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 2/4] x86/stackvalidate: Compile-time stack validation Josh Poimboeuf
2015-07-07 22:57 ` Andy Lutomirski
2015-07-07 23:29 ` Josh Poimboeuf
2015-07-07 23:35 ` Andy Lutomirski
2015-07-07 23:48 ` Josh Poimboeuf [this message]
2015-07-09 21:31 ` Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 3/4] x86/stackvalidate: Add file and directory ignores Josh Poimboeuf
2015-07-07 14:54 ` [PATCH v6 4/4] stackvalidate: Add ignore macros Josh Poimboeuf
2015-07-07 22:00 ` Andy Lutomirski
2015-07-07 22:59 ` Josh Poimboeuf
2015-07-07 23:00 ` Andy Lutomirski
2015-07-07 23:38 ` Josh Poimboeuf
2015-07-07 15:06 ` [PATCH v6 0/4] Compile-time stack validation Josh Poimboeuf
2015-07-07 22:35 ` 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=20150707234837.GE31294@treble.redhat.com \
--to=jpoimboe@redhat.com \
--cc=andi@firstfloor.org \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=palves@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.