From patchwork Wed Feb 1 23:04:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9550767 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 A15D360424 for ; Wed, 1 Feb 2017 23:04:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C25728305 for ; Wed, 1 Feb 2017 23:04:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F76028450; Wed, 1 Feb 2017 23:04:29 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B1AB28305 for ; Wed, 1 Feb 2017 23:04:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751866AbdBAXE2 (ORCPT ); Wed, 1 Feb 2017 18:04:28 -0500 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36847 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751861AbdBAXE1 (ORCPT ); Wed, 1 Feb 2017 18:04:27 -0500 Received: by mail-pf0-f181.google.com with SMTP id 189so121937749pfu.3 for ; Wed, 01 Feb 2017 15:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=iItLX3o5gXKakPI5rh9O8E3B4oa7YTeTsYo6YUDPnNM=; b=N5AgfD6FUIXxBt1nYyqv0uAPhm+p0bP2QjGF0GG3je5tlYVXhSQznvbyDWup5ec5gt S2ozkVe+ZyyLA8qgTYb/j0mUVEFUK0NPUMZ1PoC+Amxoc8rmPl+5BMqzTH1qtkN0G4ga CEb6dF/YjfzKUy8YmjF/n8ByV96WtVE3tJ9GA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=iItLX3o5gXKakPI5rh9O8E3B4oa7YTeTsYo6YUDPnNM=; b=tnV+u9vHNVF8gEMdHwnE2M5v3txHXLB8kh9SYlmPOJwO6XE0cqsv6Gj1YGXTQ/P+NH ywFB4xycUKgEnMk41TYtWdamWoJxoa5vpNnbSLIDikteh6lJqoszXVP/63ZgkYXok68S MnvAAi5n8VtsiI2oQjGklY+YSwvuRc/QULbGormMwGoDiL21g6znfU1Ttp3ic1lUUb+9 7K2xLargZGqjLM+8sNbB3K73dEKpFUfI2b/HOZjIWoyS1t48d3JFPnI5guzY82qkotOV 5s59V491cz9NMWjuQ5wb+HyJgywLc7HkCiYPB0o3eh7KSJEmXeUFJ4ziTPxJfxOaIvXd +x3g== X-Gm-Message-State: AIkVDXJQNp/cGjnH1Ck0x/JHj1BfLG4PeVn4bvDK4IlXlnCcHQQFOE/HJWD1PlUERDs70I5E X-Received: by 10.84.137.37 with SMTP id 34mr7882628plm.29.1485990266700; Wed, 01 Feb 2017 15:04:26 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id w76sm52282149pfd.74.2017.02.01.15.04.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Feb 2017 15:04:26 -0800 (PST) Date: Wed, 1 Feb 2017 15:04:25 -0800 From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Michal Marek , linux-kbuild@vger.kernel.org Subject: [PATCH] Kbuild: support designated_init attribute Message-ID: <20170201230425.GA75891@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a structure is marked with __attribute__((designated_init)) from GCC or Sparse, it needs to have all static initializers using designated initialization. Fail the build for any missing cases. This attribute will be used by the randstruct plugin to make sure randomized structures are being correctly initialized. Signed-off-by: Kees Cook --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index 96b27a888285..d4e0550e7abd 100644 --- a/Makefile +++ b/Makefile @@ -793,6 +793,9 @@ KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) # enforce correct pointer usage KBUILD_CFLAGS += $(call cc-option,-Werror=incompatible-pointer-types) +# Require designated initializers for all marked structures +KBUILD_CFLAGS += $(call cc-option,-Werror=designated-init) + # use the deterministic mode of AR if available KBUILD_ARFLAGS := $(call ar-option,D)