From patchwork Mon Mar 26 12:03:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Zijlstra X-Patchwork-Id: 10307717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2269A600F6 for ; Mon, 26 Mar 2018 12:04:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0FF0C2965A for ; Mon, 26 Mar 2018 12:04:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02CEA2965D; Mon, 26 Mar 2018 12:04:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 250932965A for ; Mon, 26 Mar 2018 12:03:59 +0000 (UTC) Received: (qmail 29864 invoked by uid 550); 26 Mar 2018 12:03:57 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 28575 invoked from network); 26 Mar 2018 12:03:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=+GDMUFAlQagOXvSmtV8VMElUcNLGA3s2f9E00sE9WKk=; b=uIzcNMbCG/3DGSnYcrlEnTc3H HYnff+izrmYUnXzG6upSNkz+Za9+JxwW4onjdbyamps/oD0u8r3BEXw3aCbY7CYDjFUmDYbkSiqou NqIIhqXNe1ca0YPoVHPMQmQN9u3QH7s0TOZI7LsQTW6MF1FaZLFu3uzaJ2jSOnGKYZKoJ5IiFFur6 V/aojTQrvVadEez09XSZ6fmvuXXwle33LRzoc0VAI7lf+9Del1jsI6N10hfv9ir5JuGD1ADPw1MLp 0Bamt/yR2mmg5P2wK7ZMRZAH8pxgRHIW7GIALlM58ALR19ns4VCwz2+uSUWWstq57hWK0aY1YfL5j W5RVtl7lg==; Date: Mon, 26 Mar 2018 14:03:21 +0200 From: Peter Zijlstra To: Kees Cook Cc: kernel-hardening@lists.openwall.com, Linus Torvalds , linux-kernel@vger.kernel.org, Ingo Molnar Subject: Re: [PATCH 1/4] task_struct: Allow randomized layout Message-ID: <20180326120321.GD4129@hirez.programming.kicks-ass.net> References: <1497905801-69164-1-git-send-email-keescook@chromium.org> <1497905801-69164-2-git-send-email-keescook@chromium.org> <20180326115246.GA4147@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20180326115246.GA4147@hirez.programming.kicks-ass.net> User-Agent: Mutt/1.9.3 (2018-01-21) X-Virus-Scanned: ClamAV using ClamSMTP On Mon, Mar 26, 2018 at 01:52:46PM +0200, Peter Zijlstra wrote: > That now looks like: > > struct task_struct { > struct thread_info thread_info; /* 0 16 */ > volatile long int state; /* 16 8 */ > > /* XXX 40 bytes hole, try to pack */ > > /* --- cacheline 1 boundary (64 bytes) --- */ > struct { > void * stack; /* 64 8 */ > atomic_t usage; /* 72 4 */ > unsigned int flags; /* 76 4 */ > unsigned int ptrace; /* 80 4 */ > struct llist_node wake_entry; /* 88 8 */ > > > Can we please undo this crap? The below gets rid of that nonsense. diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index e2c7f4369eff..767cf74d61f7 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -242,6 +242,15 @@ #if defined(RANDSTRUCT_PLUGIN) && !defined(__CHECKER__) #define __randomize_layout __attribute__((randomize_layout)) #define __no_randomize_layout __attribute__((no_randomize_layout)) +/* + * RANDSTRUCT_PLUGIN wants to use an anonymous struct, but it is only + * possible since GCC 4.6. To provide as much build testing coverage + * as possible, this is used for all GCC 4.6+ builds, and not just on + * RANDSTRUCT_PLUGIN builds. + */ +#define randomized_struct_fields_start struct { +#define randomized_struct_fields_end } __randomize_layout; + #endif #endif /* GCC_VERSION >= 40500 */ @@ -256,15 +265,6 @@ */ #define __visible __attribute__((externally_visible)) -/* - * RANDSTRUCT_PLUGIN wants to use an anonymous struct, but it is only - * possible since GCC 4.6. To provide as much build testing coverage - * as possible, this is used for all GCC 4.6+ builds, and not just on - * RANDSTRUCT_PLUGIN builds. - */ -#define randomized_struct_fields_start struct { -#define randomized_struct_fields_end } __randomize_layout; - #endif /* GCC_VERSION >= 40600 */