From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755730AbdCUAOR (ORCPT ); Mon, 20 Mar 2017 20:14:17 -0400 Received: from mail-pg0-f50.google.com ([74.125.83.50]:35008 "EHLO mail-pg0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755278AbdCUAOO (ORCPT ); Mon, 20 Mar 2017 20:14:14 -0400 Date: Mon, 20 Mar 2017 17:14:11 -0700 From: Kees Cook To: Masahiro Yamada Cc: Michal Marek , linux-kbuild@vger.kernel.org, Josh Triplett , linux-kernel@vger.kernel.org Subject: [PATCH v2] Kbuild: make designated_init attribute fatal Message-ID: <20170321001411.GA142235@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- v2: update subject to more clearly describe change, Masahiro Yamada --- Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Makefile b/Makefile index b841fb36beb2..142ab7b96130 100644 --- a/Makefile +++ b/Makefile @@ -795,6 +795,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) -- 2.7.4 -- Kees Cook Pixel Security