From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1037187AbdE0BN5 (ORCPT ); Fri, 26 May 2017 21:13:57 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:32901 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S944897AbdEZUXu (ORCPT ); Fri, 26 May 2017 16:23:50 -0400 MIME-Version: 1.0 In-Reply-To: <1495829844-69341-20-git-send-email-keescook@chromium.org> References: <1495829844-69341-1-git-send-email-keescook@chromium.org> <1495829844-69341-20-git-send-email-keescook@chromium.org> From: Linus Torvalds Date: Fri, 26 May 2017 13:23:49 -0700 X-Google-Sender-Auth: Gsw2tY5FoqSltXdUwMbGi0x2-Fg Message-ID: Subject: Re: [PATCH v2 19/20] [RFC] task_struct: Allow randomized layout To: Kees Cook Cc: "kernel-hardening@lists.openwall.com" , Laura Abbott , "the arch/x86 maintainers" , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 26, 2017 at 1:17 PM, Kees Cook 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?