Re: [PATCH v2 19/20] [RFC] task_struct: Allow randomized layout
From: Linus Torvalds
Date: Fri May 26 2017 - 21:14:01 EST
On Fri, May 26, 2017 at 1:17 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> This marks most of the layout of task_struct as randomizable, but leaves
> thread_info and scheduler state untouched at the start, and thread_struct
> untouched at the end.
I think you want to abstract this out somehow, because this is both
ugly and bad:
> + /* This begins the randomizable portion of task_struct... */
> +#if GCC_VERSION >= 40600
> + struct {
> +#endif
when you could instead just introduce something like
#if GCC_VERSION >= 40600
#define randomized_struct_fields_start struct {
#define randomized_struct_fields_end } __randomize_layout;
#else
#define randomized_struct_fields_start
#define randomized_struct_fields_end
#endif
and then this pattern is
(a) more-or-less self-documenting
(b) usable in other places too.
(c) maybe some future compiler wants that struct field to have some
"randomize-me attribute" or something
Hmm?