From: Kees Cook Date: Sat, 3 May 2025 18:46:19 +0000 (-0700) Subject: randstruct: Force full rebuild when seed changes X-Git-Tag: v6.16-rc1~151^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=056000c471ea41db56de58f71b9fe727d6e68b9b;p=thirdparty%2Fkernel%2Flinux.git randstruct: Force full rebuild when seed changes 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. Link: https://lore.kernel.org/r/20250503184623.2572355-2-kees@kernel.org Reviewed-by: Nicolas Schier Tested-by: Nicolas Schier Signed-off-by: Kees Cook --- diff --git a/include/linux/compiler-version.h b/include/linux/compiler-version.h index 5dba398a94129..4b9d39b376503 100644 --- a/include/linux/compiler-version.h +++ b/include/linux/compiler-version.h @@ -23,3 +23,12 @@ #ifdef GCC_PLUGINS #include #endif + +/* + * If the randstruct seed itself changes (whether for GCC plugins or + * Clang), the entire tree needs to be rebuilt since the randomization of + * structures may change between compilation units if not. + */ +#ifdef RANDSTRUCT +#include +#endif diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h index 939ceabcaf06f..335c360d4f9b9 100644 --- a/include/linux/vermagic.h +++ b/include/linux/vermagic.h @@ -33,7 +33,6 @@ #define MODULE_VERMAGIC_MODVERSIONS "" #endif #ifdef RANDSTRUCT -#include #define MODULE_RANDSTRUCT "RANDSTRUCT_" RANDSTRUCT_HASHED_SEED #else #define MODULE_RANDSTRUCT