diff options
author | Kees Cook <keescook@chromium.org> | 2018-04-10 19:32:44 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-11 13:28:35 -0400 |
commit | 2cfe0d3009418a132b93d78642a8059a38fe5944 (patch) | |
tree | be663132e62f3c0bffff1db9b13ee895b2ce6707 /include/linux/compiler-gcc.h | |
parent | d4ef8d3ff005c70f6c9e2ffea14cc65fc8fe328d (diff) |
task_struct: only use anon struct under randstruct plugin
The original intent for always adding the anonymous struct in
task_struct was to make sure we had compiler coverage.
However, this caused pathological padding of 40 bytes at the start of
task_struct. Instead, move the anonymous struct to being only used when
struct layout randomization is enabled.
Link: http://lkml.kernel.org/r/20180327213609.GA2964@beast
Fixes: 29e48ce87f1e ("task_struct: Allow randomized")
Signed-off-by: Kees Cook <keescook@chromium.org>
Reported-by: Peter Zijlstra <peterz@infradead.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/compiler-gcc.h')
-rw-r--r-- | include/linux/compiler-gcc.h | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index e2c7f4369eff..b4bf73f5e38f 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h | |||
@@ -242,6 +242,9 @@ | |||
242 | #if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__) | 242 | #if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__) |
243 | #define __randomize_layout __attribute__((randomize_layout)) | 243 | #define __randomize_layout __attribute__((randomize_layout)) |
244 | #define __no_randomize_layout __attribute__((no_randomize_layout)) | 244 | #define __no_randomize_layout __attribute__((no_randomize_layout)) |
245 | /* This anon struct can add padding, so only enable it under randstruct. */ | ||
246 | #define randomized_struct_fields_start struct { | ||
247 | #define randomized_struct_fields_end } __randomize_layout; | ||
245 | #endif | 248 | #endif |
246 | 249 | ||
247 | #endif /* GCC_VERSION >= 40500 */ | 250 | #endif /* GCC_VERSION >= 40500 */ |
@@ -256,15 +259,6 @@ | |||
256 | */ | 259 | */ |
257 | #define __visible __attribute__((externally_visible)) | 260 | #define __visible __attribute__((externally_visible)) |
258 | 261 | ||
259 | /* | ||
260 | * RANDSTRUCT_PLUGIN wants to use an anonymous struct, but it is only | ||
261 | * possible since GCC 4.6. To provide as much build testing coverage | ||
262 | * as possible, this is used for all GCC 4.6+ builds, and not just on | ||
263 | * RANDSTRUCT_PLUGIN builds. | ||
264 | */ | ||
265 | #define randomized_struct_fields_start struct { | ||
266 | #define randomized_struct_fields_end } __randomize_layout; | ||
267 | |||
268 | #endif /* GCC_VERSION >= 40600 */ | 262 | #endif /* GCC_VERSION >= 40600 */ |
269 | 263 | ||
270 | 264 | ||