lkml.org 
[lkml]   [2018]   [Sep]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v2 2/2] powerpc/32: add stack protector support
On Wed, Sep 19, 2018 at 11:14:45AM +0000, Christophe Leroy wrote:
> --- a/arch/powerpc/Makefile
> +++ b/arch/powerpc/Makefile
> @@ -112,6 +112,10 @@ KBUILD_LDFLAGS += -m elf$(BITS)$(LDEMULATION)
> KBUILD_ARFLAGS += --target=elf$(BITS)-$(GNUTARGET)
> endif
>
> +cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard=tls
> +cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-reg=r2
> +cflags-$(CONFIG_STACKPROTECTOR) += -mstack-protector-guard-offset=4

This last line is only correct if !CONFIG_THREAD_INFO_IN_TASK; is that
always true? Add an assert somewhere maybe?

> + /*
> + * The stack_canary must be located at the offset given to
> + * -mstack-protector-guard-offset in the Makefile
> + */
> + BUILD_BUG_ON(offsetof(struct task_struct, stack_canary) != sizeof(long));

Well this will help :-)

It looks like it will be easy to enable on 64 bit as well.

> + /* Try to get a semi random initial value. */
> + get_random_bytes(&canary, sizeof(canary));
> + canary ^= mftb();
> + canary ^= LINUX_VERSION_CODE;

These last two lines are useless (or worse, they may give people the idea
that they are not!)
You should use wait_for_random_bytes I think.


Segher

\
 
 \ /
  Last update: 2018-09-19 15:28    [W:0.212 / U:0.168 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site