From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
live-patching@vger.kernel.org, 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>,
Pedro Alves <palves@redhat.com>,
Namhyung Kim <namhyung@gmail.com>,
Bernd Petrovitsch <bernd@petrovitsch.priv.at>,
Chris J Arges <chris.j.arges@canonical.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v11 03/20] x86/stackvalidate: Compile-time stack validation
Date: Thu, 27 Aug 2015 09:29:53 -0500 [thread overview]
Message-ID: <20150827142953.GC26200@treble.redhat.com> (raw)
In-Reply-To: <20150826142628.GN1747@two.firstfloor.org>
On Wed, Aug 26, 2015 at 04:26:28PM +0200, Andi Kleen wrote:
> > b) 100% reliable stack traces for DWARF enabled kernels
> >
> > This is not yet implemented. See Documentation/stack-validation.txt
> > for more details about what is planned.
>
> The automatic CFI generation tool seems like a bad idea to me. There's not
> that much assembler code in Linux, and often when new assembler code is added
> it is something tricky. In this case you may end up spending more time
> fixing the tool than just fixing the assembler.
>
> It would be also quite bad to require people who want to add some
> new assembler code to learn how to fix your tool to make their
> assembler work.
Really I don't see that being much of a problem. The enforced rules
were probably too stringent in earlier versions of the patch set. But I
relaxed the rules quite a bit and now they allow things like sibling
calls, jumps to outside the function, alternatives, etc.
Generally it's easy and straightforward to follow the rules and make the
tool happy. If you're trying to do something too weird, then yes the
tool will complain, but IMO that's a good thing as it really makes you
consider whether the weirdness (and associated complexity) is justified.
I tried to document everything an asm coder would need to know. Also I
have an invested interest in keeping the tool working and useful, and
I'm listed in the MAINTAINERS file. So any frustrated people will know
who to yell at.
> It also wouldn't surprise me if there are some possible assembler tricks
> that are very hard/impossible to handle for a tool. For example how do you
> have alternative() style patching? (that's a generic problem with
> your approach BTW)
Yeah, there are definitely a lot of these tricks, but the tool can
already handle them today: alternatives, jump labels, exception tables,
gcc switch jump tables. It's usually a matter of parsing a special
section and then treating these alternative code paths as conditional
branches which need to be recursively followed and analyzed.
When such conditional branches converge, it ensures that they have the
same debug state at the convergence point.
> Doing some kind of CFI verifier would seem more feasible, but it would
> need a black/white list to override it to handle the above cases.
CFI generation isn't any harder than validation. Either way the tool
needs to do the code analysis which involves recursively following all
branches and associating a debug state with each instruction. At the
end it either compares those debug states with existing CFI, or writes
them as new CFI.
Also there are already some whitelist mechanisms for ignoring files,
functions, or instructions.
> BTW how do handle the increasing number of JITs in the kernel?
Yeah, compile-time CFI wouldn't be applicable for code which is
generated at runtime. Maybe we will need a mechanism to allow eBPF to
quickly create minimal CFI-like metadata corresponding to the JIT code
it generates, which can be used by stack dumping code to identify the
JIT code and find the previous stack pointer on the stack.
We can also add a debug NMI handler which validates stacks periodically
to ensure that stacks are always sane.
--
Josh
next prev parent reply other threads:[~2015-08-27 14:29 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-24 14:45 [PATCH v11 00/20] Compile-time stack validation Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 01/20] x86/asm: Frame pointer macro cleanup Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 02/20] x86/asm: Add C versions of frame pointer macros Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 03/20] x86/stackvalidate: Compile-time stack validation Josh Poimboeuf
2015-08-26 14:26 ` Andi Kleen
2015-08-27 14:29 ` Josh Poimboeuf [this message]
2015-08-28 17:26 ` Andi Kleen
2015-08-28 19:54 ` Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 04/20] x86/stackvalidate: Add file and directory ignores Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 05/20] x86/stackvalidate: Add ignore macros Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 06/20] x86/xen: Add stack frame dependency to hypercall inline asm calls Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 07/20] x86/paravirt: Add stack frame dependency to PVOP " Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 08/20] x86/paravirt: Create a stack frame in PV_CALLEE_SAVE_REGS_THUNK Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 09/20] x86/amd: Set ELF function type for vide() Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 10/20] x86/reboot: Add ljmp instructions to stackvalidate whitelist Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 11/20] x86/xen: Add xen_cpuid() and xen_setup_gdt() to stackvalidate whitelists Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 12/20] x86/asm/crypto: Create stack frames in aesni-intel_asm.S Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 13/20] x86/asm/crypto: Move .Lbswap_mask data to .rodata section Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 14/20] x86/asm/crypto: Move jump_table " Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 15/20] x86/asm/crypto: Create stack frames in clmul_ghash_mul/update() Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 16/20] x86/asm/entry: Create stack frames in thunk functions Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 17/20] x86/asm/acpi: Create a stack frame in do_suspend_lowlevel() Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 18/20] x86/asm: Create stack frames in rwsem functions Josh Poimboeuf
2015-08-24 14:45 ` [PATCH v11 19/20] x86/asm/efi: Create a stack frame in efi_call() Josh Poimboeuf
2015-08-24 14:46 ` [PATCH v11 20/20] x86/asm/power: Create stack frames in hibernate_asm_64.S Josh Poimboeuf
2015-08-25 8:05 ` [PATCH v11 00/20] Compile-time stack validation Ingo Molnar
2015-08-25 15:25 ` Josh Poimboeuf
2015-08-26 7:07 ` Ingo Molnar
2015-08-26 8:44 ` Jiri Kosina
2015-08-27 13:11 ` Josh Poimboeuf
2015-08-28 8:21 ` Ingo Molnar
2015-08-28 13:54 ` Josh Poimboeuf
2015-09-14 13:19 ` Ingo Molnar
2015-09-14 14:10 ` 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=20150827142953.GC26200@treble.redhat.com \
--to=jpoimboe@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=bernd@petrovitsch.priv.at \
--cc=bp@alien8.de \
--cc=chris.j.arges@canonical.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=live-patching@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=mmarek@suse.cz \
--cc=namhyung@gmail.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox