Re: [PATCH v7 23/27] x86/cet/shstk: ELF header parsing of Shadow Stack

From: Peter Zijlstra
Date: Fri Jun 07 2019 - 03:58:53 EST


On Thu, Jun 06, 2019 at 01:06:42PM -0700, Yu-cheng Yu wrote:

> +#ifdef CONFIG_ARCH_USE_GNU_PROPERTY
> +int arch_setup_property(void *ehdr, void *phdr, struct file *f, bool inter)
> +{
> + int r;
> + uint32_t property;

Flip those two lines around.

> +
> + r = get_gnu_property(ehdr, phdr, f, GNU_PROPERTY_X86_FEATURE_1_AND,
> + &property);
> +
> + memset(&current->thread.cet, 0, sizeof(struct cet_status));

It seems to me that memset would be better placed before
get_gnu_property().

> + if (r)
> + return r;
> +
> + if (cpu_feature_enabled(X86_FEATURE_SHSTK)) {

if (r || !cpu_feature_enabled())
return r;

> + if (property & GNU_PROPERTY_X86_FEATURE_1_SHSTK)
> + r = cet_setup_shstk();
> + if (r < 0)
> + return r;
> + }
> + return r;

and loose the indent.

> +}
> +#endif
> --
> 2.17.1
>