From patchwork Fri May 26 20:17:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9751079 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 46E4160246 for ; Fri, 26 May 2017 20:18:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38C6B28179 for ; Fri, 26 May 2017 20:18:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B93A2821F; Fri, 26 May 2017 20:18:25 +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 3236328179 for ; Fri, 26 May 2017 20:18:24 +0000 (UTC) Received: (qmail 4075 invoked by uid 550); 26 May 2017 20:18:13 -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 3956 invoked from network); 26 May 2017 20:18:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=MsZ1RDpOd+/gQ0UKSbAfD9HrkAco5A2wHCppoZTM+pg=; b=GbpyZ1GnL2B53mjVH2IppED6HETI61sI9WWykiglkgoVaiQUnKzv1xKzBbFnNXQL7B B6nRnPd+9kVzHXwKtqzciF+4M5/6IqkVUgvhlRALHtrAxgx/YaNsL8h2DBu3UtnnVCGL 7BcpZ4RbQS4+Rc5yIIB/vVknok88GLkT0gFxE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=MsZ1RDpOd+/gQ0UKSbAfD9HrkAco5A2wHCppoZTM+pg=; b=or8kPyPkjlxf1gvSUOBzYzPQdUewMs4oTvTmNjDQsndpPi0jxfwFzg/I9Pmt+QOJYa zhQMQZkvPfXWm9V5iOJ3NWVYIJpyGN4xSk6qTsZvWFSTToLzBFeKYVLoF+JZkYMQK3Jo 1kzHulWinZLvBfFQQyTI43vzAgYUdSHeAP2lB7aq3XFktiZVQJQ+Z0L10JSY+w5BHbBY zz+MrPM5qyRlVG4P9Ar449LeaANeZnYsVHIFLGmLdC7Wn2FWmiy+bL+p/SpoxgOojgms Nh/Q8uOeuOtW92HMiQL/nuUlM8avTBonp8UHLeLYQL7//Hks9YrqzQ4tKulAaxLwaPU+ 9wUQ== X-Gm-Message-State: AODbwcBBCp0EwoQXTvbptzb00c+eNEYtVMXIvqhNGWz/2MyT88qA4/lU cHOiP5r4/JTGNffD X-Received: by 10.99.113.74 with SMTP id b10mr4600397pgn.139.1495829880177; Fri, 26 May 2017 13:18:00 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Laura Abbott , x86@kernel.org, linux-kernel@vger.kernel.org Date: Fri, 26 May 2017 13:17:07 -0700 Message-Id: <1495829844-69341-4-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495829844-69341-1-git-send-email-keescook@chromium.org> References: <1495829844-69341-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v2 03/20] compiler: Add __designated_init annotation X-Virus-Scanned: ClamAV using ClamSMTP This allows structure annotations for requiring designated initialization in GCC 5.1.0 and later: https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html The structure randomization layout plugin will be using this to help identify structures that need this form of initialization. Signed-off-by: Kees Cook --- include/linux/compiler-gcc.h | 8 ++++++++ include/linux/compiler.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h index 0efef9cf014f..386caf6771ed 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -294,6 +294,14 @@ #define __no_sanitize_address __attribute__((no_sanitize_address)) #endif +#if GCC_VERSION >= 50100 +/* + * Mark structures as requiring designated initializers. + * https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html + */ +#define __designated_init __attribute__((designated_init)) +#endif + #endif /* gcc version >= 40000 specific checks */ #if !defined(__noclone) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 707242fdbb89..bbe881054bf0 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -436,6 +436,10 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s # define __attribute_const__ /* unimplemented */ #endif +#ifndef __designated_init +# define __designated_init +#endif + #ifndef __latent_entropy # define __latent_entropy #endif