From patchwork Thu Apr 6 21:18:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9668447 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 86F4C602B3 for ; Thu, 6 Apr 2017 21:19:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C31E1285E4 for ; Thu, 6 Apr 2017 21:19:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7E1D285E8; Thu, 6 Apr 2017 21:19:39 +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 D463C285E4 for ; Thu, 6 Apr 2017 21:19:38 +0000 (UTC) Received: (qmail 29814 invoked by uid 550); 6 Apr 2017 21:19:21 -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 28584 invoked from network); 6 Apr 2017 21:19:16 -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=Pjh8ta450o2Dglg4UYsSP9QYykA5dApLQhMkotgYp4I=; b=Ur3t41efjwxV2BllES4MM0cra28RWZ+gaFxxlDS1dORkUcWU2T6ycudKiFcOpcxrMF bg/JElR4sqdM+nseAXFeAMoLKlmFJNf3xYs0zJa2Pr5h1PfOItQS4Mhvij7KJlgmj7fj rPozK2n8s9M7WEtE8FujykqlvlFdCDWLPKT8o= 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=Pjh8ta450o2Dglg4UYsSP9QYykA5dApLQhMkotgYp4I=; b=KXft2ov06qukuCaxYjRWrIW6K8xMwfha1QSezF2rv6qNfn6pYtngTOLuntnLL9hokA 8AXPwa01Hmn0OU66Ewg1FcLNnV4RRVM6fjiV9l1E9I287n1LCwKMUx/OJBlZ+fCy1p/h GiwrWI6ra27zS9dMxZLkXH0vkSUiX0ImvQS3N5Pi96ocsmGTHlu0i1uOyvqmO5URzA+M 9bK1Ex7T2jb3PKb+AT0Fa/TDEleZq5dIzvTbxxOHKc+XqSsxmu8/w/xGxzgkkM2pB93B K4+dG4Y5TSnN2VfbXUSAEEMvNIYIzWYCfAvJsRr4aKTwXxHfBznf9uvQiPz9PaXCouml EbyA== X-Gm-Message-State: AFeK/H1ctkNoOHkaJfL3EWBl1DxtkxqSHdN6IA1gU/Cxej7/pZmhDUrnr1X2avpQwoz2cpZ7 X-Received: by 10.99.167.74 with SMTP id w10mr38402138pgo.2.1491513544565; Thu, 06 Apr 2017 14:19:04 -0700 (PDT) From: Kees Cook To: kernel-hardening@lists.openwall.com Cc: Kees Cook , Michael Leibowitz Date: Thu, 6 Apr 2017 14:18:17 -0700 Message-Id: <1491513513-84351-3-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1491513513-84351-1-git-send-email-keescook@chromium.org> References: <1491513513-84351-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 02/18] 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 5f4d8f8b75da..cf541e49841e 100644 --- a/include/linux/compiler-gcc.h +++ b/include/linux/compiler-gcc.h @@ -321,6 +321,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 b8642a3a1f4f..40e584448605 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -440,6 +440,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