From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1037221AbdE0BOW (ORCPT ); Fri, 26 May 2017 21:14:22 -0400 Received: from mail-io0-f177.google.com ([209.85.223.177]:34038 "EHLO mail-io0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S944907AbdEZUc2 (ORCPT ); Fri, 26 May 2017 16:32:28 -0400 MIME-Version: 1.0 In-Reply-To: References: <1495829844-69341-1-git-send-email-keescook@chromium.org> <1495829844-69341-20-git-send-email-keescook@chromium.org> From: Kees Cook Date: Fri, 26 May 2017 13:32:26 -0700 X-Google-Sender-Auth: _gFWwv9rCsUlBsMDm6aUw21nk2c Message-ID: Subject: Re: [PATCH v2 19/20] [RFC] task_struct: Allow randomized layout To: Linus Torvalds 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:23 PM, Linus Torvalds wrote: > 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? There were so many options and they all seems weird for various reason. :) I'll use your idea, it looks much cleaner, thanks! -Kees -- Kees Cook Pixel Security