From patchwork Fri Aug 27 16:30:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12462341 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5D640C4320A for ; Fri, 27 Aug 2021 16:30:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4524760EFF for ; Fri, 27 Aug 2021 16:30:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234458AbhH0QbN (ORCPT ); Fri, 27 Aug 2021 12:31:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233697AbhH0QbK (ORCPT ); Fri, 27 Aug 2021 12:31:10 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDB83C0613D9 for ; Fri, 27 Aug 2021 09:30:21 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id t1so6407361pgv.3 for ; Fri, 27 Aug 2021 09:30:21 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=H+ke82JqnNzuF+ETLARNzezEA9Zqm2D4YO8akYC5ijQ=; b=e+LKzFlkLmCnm0Uy0SnczxQ2uaSczRmJXNF59sh3lJBigg5vC629YE17XCpHD+FSoi J5MHuadPZDPIu2eF09UqeeazyZBC2HvFM7F9u4P5hA8CJTmcjOn8odWBRpUoWXwl7U5Z a0mg3f87URQ4LuN2CRcXnyqlblbIOuMmkrwTs= 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:mime-version:content-transfer-encoding; bh=H+ke82JqnNzuF+ETLARNzezEA9Zqm2D4YO8akYC5ijQ=; b=fFNGTugjKLA/8/JuUB+o9clcqsf0Bq/hnnhQMgecXd0wuXgu30BLMkvATSkpqaMIvc nEBURyz7K+EOeut7swYa4f85HlYYVgbLJLrj8xVPJjTMHVSjpvAVK7qqE5Ky/tbuZFKn bXsRGBY7/9ahYqSVDx1Rk8G0jW5J7NZg6o+PBw2pOEXupoKL7iCZ+kP6nEnuPjhQ630d tleyNaukyNRaGd/aXjJLWVku+1FzQmKRudocvnz7pqzThX4mM/UNtkht+MpHE9GLO+6/ s5I2HkYRdCpF2hfe3t+JjR5XTvsHEAwDCfTr0Gwq+mdlv0s0OLfrsn1b5m+W8myuIDIx iBlA== X-Gm-Message-State: AOAM533t9HF3qiTHA/4A99kLICm1eunX3fC9f5fSeY5LG9gFj68FXJo5 4yTV7xHx+mozAPnNT0KubOW/5g== X-Google-Smtp-Source: ABdhPJzVWD5kE7Vujy3R3rBTbCRZ8VfJ1Z6Z6J4uxCGV5F6llmErtgFAj9B8vh5uJImuxxBnOoSpAg== X-Received: by 2002:a62:6143:0:b029:3c9:3117:c620 with SMTP id v64-20020a6261430000b02903c93117c620mr9956209pfb.30.1630081821279; Fri, 27 Aug 2021 09:30:21 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id q13sm13041500pjq.10.2021.08.27.09.30.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:30:18 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Arnd Bergmann , Masahiro Yamada , linux-kbuild@vger.kernel.org, "Gustavo A . R . Silva" , Rasmus Villemoes , Keith Packard , Dan Williams , Daniel Vetter , clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Subject: [PATCH v3 4/5] Makefile: Enable -Warray-bounds Date: Fri, 27 Aug 2021 09:30:14 -0700 Message-Id: <20210827163015.3141722-5-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210827163015.3141722-1-keescook@chromium.org> References: <20210827163015.3141722-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1113; h=from:subject; bh=oefMcHZzjrqvoOMjUB7suXN8EJKiDU2oIYgtW+uUBtg=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhKRMXaFIio04DmLvoRaIim4FnyDX46vN/W1R6TAc9 7X8LHOKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYSkTFwAKCRCJcvTf3G3AJkHDEA CS1lNg3ppEL752ZcERsA8g+c+eYjHTxh15ZTmzUnEtLj6BwMfdbA4/x1xXrjYx1Bg3dJBsGFGhhpQt ozHruyY7Oo7N981nkjQ17v62G45VttSUW0Da9NH4LAmLVzsxHD0eNX4PVE5ZDbGbbH6eE5CrpdTzRJ iNUg4Bto8WHejlPUM/iWswUDI35C38Ckinp80US2/WBXEd2+4PmvnF2qkZGkmZ65WqzLdDZRh3LGu2 HBBxun0qKGvwYwui7oSaKwzCgWZKOkedPVBzfLc3xYcVrLu5swuJmTPLb7YT5WXPH2HdZI7FYqB/Py PjJtQhMrIn2yB8i83VdeCbOZ1IV70o6Eo7mSwFigYSWvtQnG3RZroi9sq1Agy027oHBW07Rvv/umF1 JhVtAHQtTEGjfr3kW89UTaY4HfFsD1JF4oi+CR12uO9+ci9R0DYPRkBFqjL2Y27danaiOyoY2u7yTx mZ6JPA0BHivZtZe/u+uSimSgojZF3B50suFMGmwa7kF/oonGQDz6IrnMy3twHYH7wzin56Vaj8oVVw B+4BrvUOeXYtj8To2ctra/tgAK26O/YGcMht6SuqX/ErTpO7QbpHL2fFyYf1kbmbIJc6vgwVesrVHg iqwNiKHwsWkpf7q4OjGMI+O6JX7fdDBcHhG2QRelqvzBoga7Vkav4a26D+iw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org With the recent fixes for flexible arrays and expanded FORTIFY_SOURCE coverage, it is now possible to enable -Warray-bounds. Since both GCC and Clang include -Warray-bounds in -Wall, we just need to stop disabling it. Cc: Arnd Bergmann Cc: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org Co-developed-by: Gustavo A. R. Silva Signed-off-by: Gustavo A. R. Silva Signed-off-by: Kees Cook --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index e4f5895badb5..8e7e73a642e2 100644 --- a/Makefile +++ b/Makefile @@ -995,7 +995,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) # We'll want to enable this eventually, but it's not going away for 5.7 at least KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) -KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) # Another good warning that we'll want to enable eventually From patchwork Fri Aug 27 16:30:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 12462343 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 836B1C25AEC for ; Fri, 27 Aug 2021 16:30:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6E15860F14 for ; Fri, 27 Aug 2021 16:30:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237374AbhH0Qb0 (ORCPT ); Fri, 27 Aug 2021 12:31:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231318AbhH0QbV (ORCPT ); Fri, 27 Aug 2021 12:31:21 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CDCEC0613D9 for ; Fri, 27 Aug 2021 09:30:32 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id m4so4297389pll.0 for ; Fri, 27 Aug 2021 09:30:32 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=wUGiyr3xsPMSx8OhiS6MBjOzSMfwTo6qvLGkcomqylk=; b=fp4bpLYYPI+3WOpsTvOtEeHprf2IR2AKq6W/3xnQzzVUCltG6pZHvyAJF2Uo4qOQcI AIJzz21a/RRTPLMNI3o6iG17hcRzEjY2LXxBOn9zlXopEM7eZUuDpNawxS7KUhRn4UMS Ngc1Uer/Aq8RxX7P+GLs5CVqdQXE6DzRmBbfw= 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:mime-version:content-transfer-encoding; bh=wUGiyr3xsPMSx8OhiS6MBjOzSMfwTo6qvLGkcomqylk=; b=GmI4J6Eq4KNVaYoMa/LZ/KSgZlso8OG3OBrmf2yRCXYBr1gEfKnY1pyNuc+LvWOxgL Wl2xf144/nZpu+cZ5vUUAX4N2/tXNQeTdHCHY8Fm4L5liv7jon+ge0ak+x3ea97jl5Pm tedRP/C4ZKqr1d3StjeR0MjrOck1hW0y3Xq51iEQ+ZC0bqjVsZhFpJ70JkMctEGMc7yg zQAOdahDG+9qVQmvFuxe3CyvtvS855VyDaKg27PsIXg14MVIX1o4hRN8/eB9goOwxOII bk6AeLMBEg2bEZva3LXKXNfVeI9hktmuBRb4KFkyALc3zbMgkXUfcOTvlp73xYYMUjnf jaIA== X-Gm-Message-State: AOAM533xTn3uHjwl5iDzenmT/e06p0AqvHR1jM1UbWVbizQykNbRp0kA b4CF+0iYHXHr3aoO1F2vAEFyKQ== X-Google-Smtp-Source: ABdhPJxC0+0qNud6ZTr6aglKyM9SV2kAn2ypTGmgEhPWqQ1vUABPB06D5nBNxiIx4J1MtQmzkiTV5A== X-Received: by 2002:a17:902:744c:b0:136:a8cb:a05 with SMTP id e12-20020a170902744c00b00136a8cb0a05mr9520190plt.72.1630081831590; Fri, 27 Aug 2021 09:30:31 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id x16sm7444696pgc.49.2021.08.27.09.30.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Aug 2021 09:30:29 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , "Gustavo A. R. Silva" , Arnd Bergmann , Masahiro Yamada , linux-kbuild@vger.kernel.org, Rasmus Villemoes , Keith Packard , Dan Williams , Daniel Vetter , clang-built-linux@googlegroups.com, linux-hardening@vger.kernel.org Subject: [PATCH v3 5/5] Makefile: Enable -Wzero-length-bounds Date: Fri, 27 Aug 2021 09:30:15 -0700 Message-Id: <20210827163015.3141722-6-keescook@chromium.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210827163015.3141722-1-keescook@chromium.org> References: <20210827163015.3141722-1-keescook@chromium.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=996; h=from:subject; bh=/SN5+6T3ztIGtswjzUhGWY/cmKXtgVAB5r1vX4FHhD8=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBhKRMX4PEFBk7l4lz+prByvaAJlFG/Y2kCmVwrumJm JhcDUiyJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCYSkTFwAKCRCJcvTf3G3AJizPD/ 92QLLpXTpLLRbzzzUB0IeioWQMIASzu0K89wSsZYLn2LG8ukNzwMXgyCoq+RMzJi64FthppGJC4dxn 5waUOlOPI9Ck0FaQ+xaR+apjpwbHPLFUbRDFdyUnKZg7O4l6av1TCIMvNuy6kUvc9DiPPCeRhdJzOt 3PeVgCh/kiVQlZo3Lp/+fypoWYtwJ63sUk8oMYoO84eyPcGo1AxVkUDf7sCBFsSNkwl54aukpDN8hf 3cTSGKtAjZhbGsZWY0Ss/Sgly58d7vt/muhqP+671muebBbWRt/gbKpYVw4kWGFZN4ND71kbpgffG4 Z0Pg6pc8oBC1b7y7RApdPHMWVXidsmJ2gHUd+11zidZZmrrOOkd6eW/RDMh2T5BCmQqm/vy9RJpOOH WPGdPwqHWFpPaLKUpVap6svg3uoGlfiuPWymjuTrHylUYbUGfj8JYlQU6J6Hiwr8uGFKqOF2v0RGeW m12csqq0mPHmmw6HWPatqh5TYvD6135KC6iGIuPJZxXWRhyNjiUw2cTqPG8z77TsYWOYbevTNzx73p 1gqJBbNM+JNygLPWnfYMiFVNAGr4jKs0t0IjRpIfxlS9uJQMuzy7ctEPaGqXsAEIVicVSGVy9BAgJ1 iJCGKyn6DOr+od18DToNiML6X9vAbLBRNDtgSXgqFNXdJYyuU0+Fygr4T43A== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org With all known internal zero-length accesses fixed, it is possible to enable -Wzero-length-bounds globally. Since this is included by default in -Warray-bounds, we just need to stop disabling it. Cc: "Gustavo A. R. Silva" Cc: Arnd Bergmann Cc: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org Signed-off-by: Kees Cook --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 8e7e73a642e2..8e732e875e78 100644 --- a/Makefile +++ b/Makefile @@ -994,7 +994,6 @@ KBUILD_CFLAGS += -Wno-pointer-sign KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) # We'll want to enable this eventually, but it's not going away for 5.7 at least -KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) # Another good warning that we'll want to enable eventually