From patchwork Tue Jun 26 17:40:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10489875 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 1E27E60386 for ; Tue, 26 Jun 2018 17:40:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0405728699 for ; Tue, 26 Jun 2018 17:40:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC542286FC; Tue, 26 Jun 2018 17:40:18 +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=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D62C628699 for ; Tue, 26 Jun 2018 17:40:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4AD646E5E0; Tue, 26 Jun 2018 17:40:17 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id A501C6E5EB for ; Tue, 26 Jun 2018 17:40:16 +0000 (UTC) Received: by mail-pf0-x244.google.com with SMTP id q1-v6so8406606pff.13 for ; Tue, 26 Jun 2018 10:40:16 -0700 (PDT) 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=gXO0h9619stsONpcqKrkcnlC2fSbgLHUz3AebFkLFD4=; b=NMNUculPSpTvxJKyhdEP+1S8k0a3B8/we0M/W9Ad8aJYDQUIzv5x9EHlfnZQncNc9Y jk81DQFE+RL9smUJihJeGx5mEKKG/jxpjUlA74eZ2UpdGGZOQxvYu/3ZVA5Nmib461G4 g/m+U5h/3BRISlXOaUF2WZWD09Fjzjeqd7GqBtzJdYWBB8QZ253zbcOoMCB0UjFB+dut jMDambz3tCbEBqAyNH2Zcu4nfxo2/2LmkA/vIZNGC4aDNYPyUPs5tO4Id17stBzBDHSI M9uhTem496uOVhFaVN/8IbTky9JFgJM1PUNRQTscGfbGp9gSEcGUHf0gutYQacUyxvEE MRdw== X-Gm-Message-State: APt69E0qxu5z57Kfe2Akszsr6jTrcGlJ4PVAD28xy49O2G7E69ZkTmww o9m0q7NY9GrP0EqL3YDrfSfaEg== X-Google-Smtp-Source: AAOMgpdtKsYtYPjgnLxeiDBJgLiH9ZJmOLRHFCxBLdIfLlMFjpHOBByhEfKQhGNFICv9/vShiE1a6g== X-Received: by 2002:a62:6c42:: with SMTP id h63-v6mr2520237pfc.240.1530034816293; Tue, 26 Jun 2018 10:40:16 -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 s12-v6sm3301985pfm.41.2018.06.26.10.40.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Jun 2018 10:40:15 -0700 (PDT) Date: Tue, 26 Jun 2018 10:40:13 -0700 From: Kees Cook To: linux-kernel@vger.kernel.org Message-ID: <20180626174013.GA41617@beast> MIME-Version: 1.0 Content-Disposition: inline Subject: [Intel-gfx] [RFC][PATCH] Makefile: globally enable VLA warning X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Michal Marek , "Gustavo A. R. Silva" , David Airlie , Sebastian Andrzej Siewior , Matt Redfearn , dri-devel@lists.freedesktop.org, Masahiro Yamada , Palmer Dabbelt , Joe Perches , Andrew Morton , Linus Torvalds , intel-gfx@lists.freedesktop.org, linux-kbuild@vger.kernel.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This is the patch I've got prepared now that fixes for all VLAs have been sent to maintainers (some are still under review/adjustment, but there aren't any unexplored cases left). My intention would be to have this land at the end of the next merge window after all the pending VLA patches have landed. I just wanted to get any feedback here, since it touches a couple areas in the process and I didn't want anyone to be surprised. :) Thanks! -Kees ---- Now that VLAs have been removed from the kernel, enable the VLA warning globally. The only exceptions to this are the KASan an UBSan tests which are explicitly checking that VLAs trigger their respective tests. Signed-off-by: Kees Cook --- Makefile | 3 +++ drivers/gpu/drm/i915/Makefile | 2 +- lib/Makefile | 2 ++ scripts/Makefile.extrawarn | 1 - 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c9132594860b..3d5013ec4116 100644 --- a/Makefile +++ b/Makefile @@ -778,6 +778,9 @@ NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) # warn about C99 declaration after statement KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) +# VLAs should not be used anywhere in the kernel +KBUILD_CFLAGS += $(call cc-option,-Wvla) + # disable pointer signed / unsigned warnings in gcc 4.0 KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile index 4c6adae23e18..289ab5dc5712 100644 --- a/drivers/gpu/drm/i915/Makefile +++ b/drivers/gpu/drm/i915/Makefile @@ -12,7 +12,7 @@ # Note the danger in using -Wall -Wextra is that when CI updates gcc we # will most likely get a sudden build breakage... Hopefully we will fix # new warnings before CI updates! -subdir-ccflags-y := -Wall -Wextra -Wvla +subdir-ccflags-y := -Wall -Wextra subdir-ccflags-y += $(call cc-disable-warning, unused-parameter) subdir-ccflags-y += $(call cc-disable-warning, type-limits) subdir-ccflags-y += $(call cc-disable-warning, missing-field-initializers) diff --git a/lib/Makefile b/lib/Makefile index 90dc5520b784..4720e276232e 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -52,7 +52,9 @@ obj-$(CONFIG_TEST_SYSCTL) += test_sysctl.o obj-$(CONFIG_TEST_HASH) += test_hash.o test_siphash.o obj-$(CONFIG_TEST_KASAN) += test_kasan.o CFLAGS_test_kasan.o += -fno-builtin +CFLAGS_test_kasan.o += $(call cc-disable-warning, vla) obj-$(CONFIG_TEST_UBSAN) += test_ubsan.o +CFLAGS_test_ubsan.o += $(call cc-disable-warning, vla) UBSAN_SANITIZE_test_ubsan.o := y obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o obj-$(CONFIG_TEST_LIST_SORT) += test_list_sort.o diff --git a/scripts/Makefile.extrawarn b/scripts/Makefile.extrawarn index 8d5357053f86..24b2fb1d1297 100644 --- a/scripts/Makefile.extrawarn +++ b/scripts/Makefile.extrawarn @@ -52,7 +52,6 @@ warning-3 += -Wpointer-arith warning-3 += -Wredundant-decls warning-3 += -Wswitch-default warning-3 += $(call cc-option, -Wpacked-bitfield-compat) -warning-3 += $(call cc-option, -Wvla) warning := $(warning-$(findstring 1, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS))) warning += $(warning-$(findstring 2, $(KBUILD_ENABLE_EXTRA_GCC_CHECKS)))