GCC_PLUGIN_RANDSTRUCT being set breaks 5.8-rc2 build
From: Caleb Jorden
Date: Wed Jun 24 2020 - 03:20:37 EST
Hi everyone,
I was trying to test out the 5.8-rc2 kernel using my standard
machine-specific config, but my build kept failing. I ended up
comparing against the x86_64_defconfig configuration (which worked)
using the config-bisect.pl script, and discovered that if
GCC_PLUGIN_RANDSTRUCT is set, I get this error:
--------------------
In file included from ./arch/x86/include/asm/atomic.h:5,
from ./include/linux/atomic.h:7,
from ./include/linux/llist.h:51,
from ./include/linux/irq_work.h:5,
from kernel/smp.c:10:
kernel/smp.c: In function âsmp_initâ:
./include/linux/compiler.h:392:38: error: call to
â__compiletime_assert_157â declared with attribute error: BUILD_BUG_ON
failed: offsetof(struct task_struct, wake_entry_type) -
offsetof(struct task_struct, wake_entry) != offsetof(struct
__call_single_data, flags) - offsetof(struct __call_single_data,
llist)
392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^
./include/linux/compiler.h:373:4: note: in definition of macro
â__compiletime_assertâ
373 | prefix ## suffix(); \
| ^~~~~~
./include/linux/compiler.h:392:2: note: in expansion of macro
â_compiletime_assertâ
392 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro
âcompiletime_assertâ
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:50:2: note: in expansion of macro âBUILD_BUG_ON_MSGâ
50 | BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
| ^~~~~~~~~~~~~~~~
kernel/smp.c:687:2: note: in expansion of macro âBUILD_BUG_ONâ
687 | BUILD_BUG_ON(offsetof(struct task_struct, wake_entry_type) -
offsetof(struct task_struct, wake_entry) !=
| ^~~~~~~~~~~~
CC fs/fs_context.o
make[1]: *** [scripts/Makefile.build:281: kernel/smp.o] Error 1
--------------------
I am able to reproduce this error now if I use the x86_64_defconfig,
and simply set GCC_PLUGIN_RANDSTRUCT from the configuration tree in:
- General architecture-dependent options
- GCC plugins
[x] Randomize layout of sensitive kernel structures
It appears the cause is this commit:
---------------------
commit a148866489fbe243c936fe43e4525d8dbfa0318f
Author: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Date: Tue May 26 18:11:04 2020 +0200
sched: Replace rq::wake_list
---------------------
I am observing these build failures on GCC 9.3.0 (Gentoo) and GCC
10.1.0 (Manjaro) using the 5.8-rc2 kernel from git
(48778464bb7d346b47157d21ffde2af6b2d39110).
I am not on the kernel mailing list, if there is anything I can do to
assist with fixing this, please copy me directly.
Thanks!
Caleb Jorden
cjorden@xxxxxxxxx