From: Michael Ellerman <mpe@ellerman•id.au>
To: Christophe Leroy <christophe.leroy@c-s•fr>,
Benjamin Herrenschmidt <benh@kernel•crashing.org>,
Paul Mackerras <paulus@samba•org>, Scott Wood <oss@buserror•net>
Cc: linux-kernel@vger•kernel.org, linuxppc-dev@lists•ozlabs.org,
Nicolas Pitre <nicolas.pitre@linaro•org>
Subject: Re: [PATCH 1/2] powerpc: initial stack protector (-fstack-protector) support
Date: Thu, 17 Nov 2016 22:05:55 +1100 [thread overview]
Message-ID: <878tsixt64.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <55ab3b5e81cc63a130df787708144bfcd43d85f1.1475181427.git.christophe.leroy@c-s.fr>
Christophe Leroy <christophe.leroy@c-s•fr> writes:
> diff --git a/arch/powerpc/include/asm/stackprotector.h b/arch/powerpc/include/asm/stackprotector.h
> new file mode 100644
> index 0000000..de00332
> --- /dev/null
> +++ b/arch/powerpc/include/asm/stackprotector.h
> @@ -0,0 +1,38 @@
> +/*
> + * GCC stack protector support.
> + *
> + * Stack protector works by putting predefined pattern at the start of
> + * the stack frame and verifying that it hasn't been overwritten when
> + * returning from the function. The pattern is called stack canary
> + * and gcc expects it to be defined by a global variable called
> + * "__stack_chk_guard" on ARM. This unfortunately means that on SMP
^
PPC
> + * we cannot have a different canary value per task.
> + */
> +
> +#ifndef _ASM_STACKPROTECTOR_H
> +#define _ASM_STACKPROTECTOR_H 1
We usually just define it, not define it to 1.
> +
> +#include <linux/random.h>
> +#include <linux/version.h>
> +
> +extern unsigned long __stack_chk_guard;
> +
> +/*
> + * Initialize the stackprotector canary value.
> + *
> + * NOTE: this must only be called from functions that never return,
> + * and it must always be inlined.
> + */
> +static __always_inline void boot_init_stack_canary(void)
> +{
> + unsigned long canary;
> +
> + /* Try to get a semi random initial value. */
> + get_random_bytes(&canary, sizeof(canary));
> + canary ^= LINUX_VERSION_CODE;
What about mixing in an mftb() as well ?
> diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
> index e59ed6a..4a62179 100644
> --- a/arch/powerpc/kernel/Makefile
> +++ b/arch/powerpc/kernel/Makefile
> @@ -19,6 +19,11 @@ CFLAGS_init.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
> CFLAGS_btext.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
> CFLAGS_prom.o += $(DISABLE_LATENT_ENTROPY_PLUGIN)
>
> +# -fstack-protector triggers protection checks in this code,
> +# but it is being used too early to link to meaningful stack_chk logic.
> +nossp_flags := $(call cc-option, -fno-stack-protector)
> +CFLAGS_prom_init.o := $(nossp_flags)
We've already assigned to CFLAGS_prom_init.o so I think you should be
using += not := shouldn't you?
Also it could just be a single line:
CFLAGS_prom_init.o += $(call cc-option, -fno-stack-protector)
cheers
next prev parent reply other threads:[~2016-11-17 11:05 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-30 14:26 [PATCH 0/2] powerpc: stack protector (-fstack-protector) support Christophe Leroy
2016-09-30 14:26 ` [PATCH 1/2] powerpc: initial " Christophe Leroy
2016-11-17 11:05 ` Michael Ellerman [this message]
2016-11-22 10:51 ` Christophe LEROY
2016-09-30 14:27 ` [PATCH 2/2] powerpc/32: stack protector: change the canary value per task Christophe Leroy
2016-09-30 16:26 ` [PATCH 0/2] powerpc: stack protector (-fstack-protector) support Denis Kirjanov
2016-09-30 16:38 ` Christophe LEROY
2016-09-30 23:17 ` Benjamin Herrenschmidt
2016-11-17 11:27 ` Michael Ellerman
2016-11-18 12:43 ` Denis Kirjanov
-- strict thread matches above, loose matches on Subject: below --
2018-09-17 12:15 [PATCH 1/2] powerpc: initial " Christophe Leroy
2018-09-17 16:21 ` kbuild test robot
2018-09-17 16:46 ` Segher Boessenkool
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=878tsixt64.fsf@concordia.ellerman.id.au \
--to=mpe@ellerman$(echo .)id.au \
--cc=benh@kernel$(echo .)crashing.org \
--cc=christophe.leroy@c-s$(echo .)fr \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=linuxppc-dev@lists$(echo .)ozlabs.org \
--cc=nicolas.pitre@linaro$(echo .)org \
--cc=oss@buserror$(echo .)net \
--cc=paulus@samba$(echo .)org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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