Skip to content

Commit 056000c

Browse files
committed
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/[email protected] Reviewed-by: Nicolas Schier <[email protected]> Tested-by: Nicolas Schier <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent 0cecd37 commit 056000c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

include/linux/compiler-version.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,12 @@
2323
#ifdef GCC_PLUGINS
2424
#include <generated/gcc-plugins.h>
2525
#endif
26+
27+
/*
28+
* If the randstruct seed itself changes (whether for GCC plugins or
29+
* Clang), the entire tree needs to be rebuilt since the randomization of
30+
* structures may change between compilation units if not.
31+
*/
32+
#ifdef RANDSTRUCT
33+
#include <generated/randstruct_hash.h>
34+
#endif

include/linux/vermagic.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#define MODULE_VERMAGIC_MODVERSIONS ""
3434
#endif
3535
#ifdef RANDSTRUCT
36-
#include <generated/randstruct_hash.h>
3736
#define MODULE_RANDSTRUCT "RANDSTRUCT_" RANDSTRUCT_HASHED_SEED
3837
#else
3938
#define MODULE_RANDSTRUCT

0 commit comments

Comments
 (0)