From patchwork Tue Mar 21 00:14:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9635639 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 00255601E9 for ; Tue, 21 Mar 2017 00:14:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E6CE627031 for ; Tue, 21 Mar 2017 00:14:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB2AE275A2; Tue, 21 Mar 2017 00:14:33 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,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 6966F27031 for ; Tue, 21 Mar 2017 00:14:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755307AbdCUAOQ (ORCPT ); Mon, 20 Mar 2017 20:14:16 -0400 Received: from mail-pg0-f54.google.com ([74.125.83.54]:34109 "EHLO mail-pg0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755292AbdCUAOO (ORCPT ); Mon, 20 Mar 2017 20:14:14 -0400 Received: by mail-pg0-f54.google.com with SMTP id 21so51810857pgg.1 for ; Mon, 20 Mar 2017 17:14:13 -0700 (PDT) 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=rau0mVl5uUe3On2+paW4V3tJaEfsSSbC8ckVx6edTtQ=; b=hfc1sQ0ObFFwylPweZvyuCiD+SKrOWx/70crGetY+eKeZAbJ4QaNk31uXjQHDdjnnB 7hKxDCr/CaKJzBfEB4eMIvxBHwQZSqdwLPU9CNlOcOUtgF3bo78TjbG+XziaQ3tOQYqS 97ok4eVCVD9ln4gqBtpBWtPm+zo7gUSOYtdpw= 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=rau0mVl5uUe3On2+paW4V3tJaEfsSSbC8ckVx6edTtQ=; b=PSZWa+B/9t6qPuOvR9hFk/MFb5NH8knaZPl2CMss7QWYrgsKNVZt5FOgAtIYIFueRj 9/1V5tqvrI1NPJTBPzX0RfBkG0W0uaFSjf3u1ABKKYpZT02ksoMRvdnFJ++QVpjozWnB 8sSLcxA4i8HuerrZAG4Nl4HP50wzZL9PJLR88Mtmj3fAeXpHWcF2IYKfzpivsSsf7LEd UWMuJyXRomckq2tdKKH3E+9oXttAjlIGKmvuTNwGtzwMLc5/DhXwLKICJ6xeBzxh91cB RkIwv7EY1rfuutBLm9UWR4FlQKKDOcda3ztMb5inqctl9BkwTYDowcfm423AGxgML7nv s+TA== X-Gm-Message-State: AFeK/H2S2TO7284alGhGwp/92eW1MsCzmcKj1Kk0lkxbi5Lx/hrL5URdKajRFPssVOLslyvS X-Received: by 10.98.67.89 with SMTP id q86mr36065755pfa.237.1490055253196; Mon, 20 Mar 2017 17:14:13 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id 23sm35335037pfz.127.2017.03.20.17.14.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Mar 2017 17:14:12 -0700 (PDT) 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-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 --- 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)