On Sat, 03 May 2025, Kees Cook wrote:

> While the randstruct GCC plugin was being rebuilt if the randstruct seed
> changed, Clang builds did not notice the change. This could result in
> differing struct layouts in a target depending on when it was built.
> 
> Include the existing generated header file in compiler-version.h when
> its associated feature name, RANDSTRUCT, is defined. This will be picked
> up by fixdep and force rebuilds where needed.
> 
> Signed-off-by: Kees Cook <[email protected]>
> ---
> Cc: Masahiro Yamada <[email protected]>
> Cc: Nathan Chancellor <[email protected]>
> Cc: Nicolas Schier <[email protected]>
> Cc: Petr Pavlu <[email protected]>
> Cc: Sebastian Andrzej Siewior <[email protected]>
> Cc: <[email protected]>
> ---
>  include/linux/compiler-version.h | 3 +++
>  include/linux/vermagic.h         | 1 -
>  2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/compiler-version.h 
> b/include/linux/compiler-version.h
> index 74ea11563ce3..69b29b400ce2 100644
> --- a/include/linux/compiler-version.h
> +++ b/include/linux/compiler-version.h
> @@ -16,3 +16,6 @@
>  #ifdef GCC_PLUGINS
>  #include <generated/gcc-plugins.h>
>  #endif
> +#ifdef RANDSTRUCT
> +#include <generated/randstruct_hash.h>
> +#endif
> diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
> index 939ceabcaf06..335c360d4f9b 100644
> --- a/include/linux/vermagic.h
> +++ b/include/linux/vermagic.h
> @@ -33,7 +33,6 @@
>  #define MODULE_VERMAGIC_MODVERSIONS ""
>  #endif
>  #ifdef RANDSTRUCT
> -#include <generated/randstruct_hash.h>
>  #define MODULE_RANDSTRUCT "RANDSTRUCT_" RANDSTRUCT_HASHED_SEED
>  #else
>  #define MODULE_RANDSTRUCT
> -- 
> 2.34.1
> 

Reviewed-by: Nicolas Schier <[email protected]>
Tested-by: Nicolas Schier <[email protected]>


Reply via email to