public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Michal Marek <mmarek@suse.cz>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
	Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org, live-patching@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 1/3] x86, stackvalidate: Compile-time stack frame pointer validation
Date: Wed, 13 May 2015 12:39:14 +0200	[thread overview]
Message-ID: <555329D2.8090909@suse.cz> (raw)
In-Reply-To: <b5b80718c3cd328d1f39649f8154211bd5d3eadb.1431362104.git.jpoimboe@redhat.com>

On 2015-05-11 18:38, Josh Poimboeuf wrote:
> Frame pointer based stack traces aren't always reliable.  One big reason
> is that most asm functions don't set up the frame pointer.
> 
> Fix that by enforcing that all asm functions honor CONFIG_FRAME_POINTER.
> This is done with a new stackvalidate host tool which is automatically
> run for every compiled .S file and which validates that every asm
> function does the proper frame pointer setup.
> 
> Also, to make sure somebody didn't forget to annotate their callable asm code
> as a function, flag an error for any return instructions which are hiding
> outside of a function.  In almost all cases, return instructions are part of
> callable functions and should be annotated as such so that we can validate
> their frame pointer usage.  A whitelist mechanism exists for those few return
> instructions which are not actually in callable code.
> 
> It currently only supports x86_64.  It *almost* supports x86_32, but the
> stackvalidate code doesn't yet know how to deal with 32-bit REL
> relocations for the return whitelists.  I tried to make the code generic
> so that support for other architectures can be plugged in pretty easily.
> 
> As a first step, all reported non-compliances result in warnings.  Right
> now I'm seeing 200+ warnings.  Once we get them all cleaned up, we can
> change the warnings to build errors so the asm code can stay clean.
> 
> Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
> ---
>  MAINTAINERS                           |   6 +
>  arch/Kconfig                          |   4 +
>  arch/x86/Kconfig                      |   1 +
>  arch/x86/Makefile                     |   6 +-
>  lib/Kconfig.debug                     |  11 ++
>  scripts/Makefile                      |   1 +
>  scripts/Makefile.build                |  22 ++-

For the kbuild parts: Acked-by: Michal Marek <mmarek@suse.cz>


> +int main(int argc, char *argv[])
> +{
> +	struct args args;
> +	struct elf *elf;
> +	struct section *sec;
> +	int ret, warnings = 0;
> +
> +	argp_parse(&argp, argc, argv, 0, 0, &args);
> +
> +	elf = elf_open(args.args[0]);
> +	if (!elf) {
> +		fprintf(stderr, "error reading elf file %s\n", args.args[0]);
> +		return 1;
> +	}
> +
> +	if (is_file_whitelisted(elf))
> +		return 0;
> +
> +	list_for_each_entry(sec, &elf->sections, list) {
> +		ret = validate_section(elf, sec);
> +		if (ret < 0)
> +			return -1;

return 1? Since this is the exit status of the program.

Michal

  reply	other threads:[~2015-05-13 10:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-11 16:38 [PATCH v3 0/3] Compile-time stack frame pointer validation Josh Poimboeuf
2015-05-11 16:38 ` [PATCH v3 1/3] x86, stackvalidate: " Josh Poimboeuf
2015-05-13 10:39   ` Michal Marek [this message]
2015-05-13 13:51     ` Josh Poimboeuf
2015-05-11 16:38 ` [PATCH v3 2/3] x86: Make push/pop CFI macros arch-independent Josh Poimboeuf
2015-05-11 16:38 ` [PATCH v3 3/3] x86, stackvalidate: Add asm frame pointer setup macros 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=555329D2.8090909@suse.cz \
    --to=mmarek@suse.cz \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=live-patching@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    --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