Message ID | 20230306220947.1982272-1-trix@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp2107891wrd; Mon, 6 Mar 2023 14:29:38 -0800 (PST) X-Google-Smtp-Source: AK7set8wHxJeOywkOUk7DR3EqjC2Mb93mRO2hLKgf1nWvneROne3+lGT76tOElrPHBchn73oqFSV X-Received: by 2002:a17:902:7582:b0:19a:a9d8:e48a with SMTP id j2-20020a170902758200b0019aa9d8e48amr11557825pll.22.1678141778698; Mon, 06 Mar 2023 14:29:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678141778; cv=none; d=google.com; s=arc-20160816; b=c0ZE3ki8Qct7QHckfV/kdoSlINc5dJRjutTqvP6lRLoWeS164zfBBAiZIsdbcGFsiz 1Dst5JzWBufKjAVcF6jFKSYOiUXgOslJi7xJK5enbjKg/cGwP2IicPsFDs+jlfBOgpgt XpMAbvzbT1HE5cFLTOZr61eCtoL6zx2u04CCjjjItjkH9JLNWlrbT7JDS+Bue/t/XpeB scNa8m29yDExPKFLyg6Din/cqlMm21BqWuR24o94/rqXlwiEDquTcuZaKjDQlunVzqYF /RKUCQNasIS3dZf3I2S/rxGF1pmdHT+6t/xXtRTsIlGad/WP4aBf9WI1Ak/nJwxoIfPi 5GFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=vOophCpjusgwUNYYPMTooXspBj++ckS+ruBhJaNGhv0=; b=0ywbfwbJ7KGeVCSzC9ZH7OQO9cp8kiAYDG3em0pd7bJiQR5y5BS2z0+fkdvUa/KPiv QPcl7YlHFfsHyF0sqv9GFMJe7MMqz3x8tbe0NF1X1QIYZmJWe+o0/2/rG3DUQTY/jAwn eVvpcaPv06ljTiCX1QozVyDP2ps1Q8w0OXgTTV2pcC0k55rTqWW6ydYFg1GMPU2iGK1t O0BhKJ+LFUr8mD+YyurctjYan5hIgb9PyKfPNycUS9uJhY/whKkonMXWaI6l/QssGWCy 4xVPY8fYvTowhpQ/V7ccU7XzPqU8LwYAm9IQyVn80TlSYbfLkJxmVYXSHJzh9FlJCevT wGYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G9vBUaad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id la5-20020a170902fa0500b00188b297f39bsi9469887plb.216.2023.03.06.14.29.25; Mon, 06 Mar 2023 14:29:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G9vBUaad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229960AbjCFWLH (ORCPT <rfc822;toshivichauhan@gmail.com> + 99 others); Mon, 6 Mar 2023 17:11:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229628AbjCFWLF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Mar 2023 17:11:05 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90C463B20A for <linux-kernel@vger.kernel.org>; Mon, 6 Mar 2023 14:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678140598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=vOophCpjusgwUNYYPMTooXspBj++ckS+ruBhJaNGhv0=; b=G9vBUaad8dHxJFxLRjfYdtHUwbt64Q7UAXgyIOH8olB9Vkyt60kMccldR/Wf0f1Z0JMA7Q J1ropCK0TyRs46mDmo/38mIYeq2+InSDA85ebYYcjNqtgaNbEkhlqgKQLznuE/WrDqEbAV SL2EOkv0CsWBUVPZkWflPjVmId/urlM= Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-450-EXgVhvnxOauqAZrGcD1eTw-1; Mon, 06 Mar 2023 17:09:57 -0500 X-MC-Unique: EXgVhvnxOauqAZrGcD1eTw-1 Received: by mail-qt1-f197.google.com with SMTP id o10-20020a05622a138a00b003bfdabf3b89so6069180qtk.13 for <linux-kernel@vger.kernel.org>; Mon, 06 Mar 2023 14:09:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678140596; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=vOophCpjusgwUNYYPMTooXspBj++ckS+ruBhJaNGhv0=; b=AnCDBc1LbVsJfNuY+J7YGqwGWv5TLfIDVsmAYcgAsCPCuH7TSAUtMl7wZOMYblW5Q4 aTKy7y76l6QZSfYJr9SazCLqU6eQ7HtRlo3dzDsMKHSbXigNf/nvvRrboMnZ2ibKKjqG XBNcIGyMW8DgK6XGPOCfTN3eyTisVD3Pofrqh829MEoXefJmgR56mfqldjrA5g3gROqS koHkrc3eliVC5Ngu8xkPpEIky+xvztQczLf8h/XllDf3j8+EoHfcYb098bnePg+ygs4O jOFtpkTKE07Cl/ctu1D/4gr98rVbDx+Yxzun38bJ2JjLGRhwPh8ZRKXb8vvfWg3rEs7j 3xxQ== X-Gm-Message-State: AO0yUKVDC4EnyVYQlyn/PQKLbO9c9Ugw5EF+Xpadk025I/qKmFY41DGA 8ju3yNwHO6kzjDsa+C0u+HaPQlFeXD0izHaW6q4OmOqEcjNCGYywuw68FNpIg541yRLNcxRyoob aqQwm1OqOfpNsVuqS/0rUQyjq X-Received: by 2002:a05:622a:134b:b0:3b6:3260:fa1d with SMTP id w11-20020a05622a134b00b003b63260fa1dmr20997327qtk.45.1678140596685; Mon, 06 Mar 2023 14:09:56 -0800 (PST) X-Received: by 2002:a05:622a:134b:b0:3b6:3260:fa1d with SMTP id w11-20020a05622a134b00b003b63260fa1dmr20997293qtk.45.1678140596472; Mon, 06 Mar 2023 14:09:56 -0800 (PST) Received: from dell-per740-01.7a2m.lab.eng.bos.redhat.com (nat-pool-bos-t.redhat.com. [66.187.233.206]) by smtp.gmail.com with ESMTPSA id d24-20020ac800d8000000b003bfaf01af24sm8432345qtg.46.2023.03.06.14.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 14:09:55 -0800 (PST) From: Tom Rix <trix@redhat.com> To: mhiramat@kernel.org, akpm@linux-foundation.org, ndesaulniers@google.com, masahiroy@kernel.org, paulmck@kernel.org, hannes@cmpxchg.org, ojeda@kernel.org, thunder.leizhen@huawei.com, christophe.leroy@csgroup.eu, vbabka@suse.cz Cc: linux-kernel@vger.kernel.org, Tom Rix <trix@redhat.com> Subject: [PATCH] init/Kconfig: extend -Wno-array-bounds to gcc 13 Date: Mon, 6 Mar 2023 17:09:47 -0500 Message-Id: <20230306220947.1982272-1-trix@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759659193656508014?= X-GMAIL-MSGID: =?utf-8?q?1759659193656508014?= |
Series |
init/Kconfig: extend -Wno-array-bounds to gcc 13
|
|
Commit Message
Tom Rix
March 6, 2023, 10:09 p.m. UTC
With gcc 13.0.1 on x86, there are several false positives like
drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:167:31:
error: array subscript 4 is above array bounds of ‘const struct sparx5_psfp_gce[4]’ [-Werror=array-bounds=]
167 | gce = &sg->gce[i];
| ~~~~~~~^~~
In file included from drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:8:
drivers/net/ethernet/microchip/sparx5/sparx5_main.h:506:32: note: while referencing ‘gce’
506 | struct sparx5_psfp_gce gce[SPX5_PSFP_GCE_CNT];
| ^~~
The code lines for the reported problem
/* For each scheduling entry */
for (i = 0; i < sg->num_entries; i++) {
gce = &sg->gce[i];
i is bounded by num_entries, which is set in sparx5_tc_flower.c
if (act->gate.num_entries >= SPX5_PSFP_GCE_CNT) {
NL_SET_ERR_MSG_MOD(extack, "Invalid number of gate entries");
return -EINVAL;
}
..
sg->num_entries = act->gate.num_entries;
So disable array-bounds as was done on gcc 11 and 12
Signed-off-by: Tom Rix <trix@redhat.com>
---
init/Kconfig | 4 ++++
1 file changed, 4 insertions(+)
Comments
+ Kees https://lore.kernel.org/lkml/20230306220947.1982272-1-trix@redhat.com/ On Mon, Mar 6, 2023 at 2:10 PM Tom Rix <trix@redhat.com> wrote: > > With gcc 13.0.1 on x86, there are several false positives like > > drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:167:31: > error: array subscript 4 is above array bounds of ‘const struct sparx5_psfp_gce[4]’ [-Werror=array-bounds=] > 167 | gce = &sg->gce[i]; > | ~~~~~~~^~~ > In file included from drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:8: > drivers/net/ethernet/microchip/sparx5/sparx5_main.h:506:32: note: while referencing ‘gce’ > 506 | struct sparx5_psfp_gce gce[SPX5_PSFP_GCE_CNT]; > | ^~~ > > The code lines for the reported problem > /* For each scheduling entry */ > for (i = 0; i < sg->num_entries; i++) { > gce = &sg->gce[i]; > > i is bounded by num_entries, which is set in sparx5_tc_flower.c > if (act->gate.num_entries >= SPX5_PSFP_GCE_CNT) { > NL_SET_ERR_MSG_MOD(extack, "Invalid number of gate entries"); > return -EINVAL; > } > .. > sg->num_entries = act->gate.num_entries; > > So disable array-bounds as was done on gcc 11 and 12 > > Signed-off-by: Tom Rix <trix@redhat.com> > --- > init/Kconfig | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/init/Kconfig b/init/Kconfig > index 1fb5f313d18f..10d0a0020726 100644 > --- a/init/Kconfig > +++ b/init/Kconfig > @@ -898,10 +898,14 @@ config GCC11_NO_ARRAY_BOUNDS > config GCC12_NO_ARRAY_BOUNDS > def_bool y > > +config GCC13_NO_ARRAY_BOUNDS > + def_bool y > + > config CC_NO_ARRAY_BOUNDS > bool > default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_ARRAY_BOUNDS > default y if CC_IS_GCC && GCC_VERSION >= 120000 && GCC_VERSION < 130000 && GCC12_NO_ARRAY_BOUNDS > + default y if CC_IS_GCC && GCC_VERSION >= 130000 && GCC_VERSION < 140000 && GCC13_NO_ARRAY_BOUNDS > > # > # For architectures that know their GCC __int128 support is sound > -- > 2.27.0 >
On March 6, 2023 2:20:50 PM PST, Nick Desaulniers <ndesaulniers@google.com> wrote: >+ Kees >https://lore.kernel.org/lkml/20230306220947.1982272-1-trix@redhat.com/ > >On Mon, Mar 6, 2023 at 2:10 PM Tom Rix <trix@redhat.com> wrote: >> >> With gcc 13.0.1 on x86, there are several false positives like >> >> drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:167:31: >> error: array subscript 4 is above array bounds of ‘const struct sparx5_psfp_gce[4]’ [-Werror=array-bounds=] >> 167 | gce = &sg->gce[i]; >> | ~~~~~~~^~~ >> In file included from drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:8: >> drivers/net/ethernet/microchip/sparx5/sparx5_main.h:506:32: note: while referencing ‘gce’ >> 506 | struct sparx5_psfp_gce gce[SPX5_PSFP_GCE_CNT]; >> | ^~~ >> >> The code lines for the reported problem >> /* For each scheduling entry */ >> for (i = 0; i < sg->num_entries; i++) { >> gce = &sg->gce[i]; >> >> i is bounded by num_entries, which is set in sparx5_tc_flower.c >> if (act->gate.num_entries >= SPX5_PSFP_GCE_CNT) { >> NL_SET_ERR_MSG_MOD(extack, "Invalid number of gate entries"); >> return -EINVAL; >> } >> .. >> sg->num_entries = act->gate.num_entries; >> >> So disable array-bounds as was done on gcc 11 and 12 GCC 13 isn't released yet, and we've been working to make Linux warning-free under -Wareay-bounds. (And we succeeded briefly with GCC 11.) I'd much rather get GCC fixed. This is due to the shift sanitizer reducing the scope of num_entries (via macro args) to 0-31, which is still >4. This seems like a hinting bug in GCC: just because the variable was used in a shift doesn't mean the compiler can make any value assumptions. -Kees
On 3/6/23 3:02 PM, Kees Cook wrote: > On March 6, 2023 2:20:50 PM PST, Nick Desaulniers <ndesaulniers@google.com> wrote: >> + Kees >> https://lore.kernel.org/lkml/20230306220947.1982272-1-trix@redhat.com/ >> >> On Mon, Mar 6, 2023 at 2:10 PM Tom Rix <trix@redhat.com> wrote: >>> With gcc 13.0.1 on x86, there are several false positives like >>> >>> drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:167:31: >>> error: array subscript 4 is above array bounds of ‘const struct sparx5_psfp_gce[4]’ [-Werror=array-bounds=] >>> 167 | gce = &sg->gce[i]; >>> | ~~~~~~~^~~ >>> In file included from drivers/net/ethernet/microchip/sparx5/sparx5_psfp.c:8: >>> drivers/net/ethernet/microchip/sparx5/sparx5_main.h:506:32: note: while referencing ‘gce’ >>> 506 | struct sparx5_psfp_gce gce[SPX5_PSFP_GCE_CNT]; >>> | ^~~ >>> >>> The code lines for the reported problem >>> /* For each scheduling entry */ >>> for (i = 0; i < sg->num_entries; i++) { >>> gce = &sg->gce[i]; >>> >>> i is bounded by num_entries, which is set in sparx5_tc_flower.c >>> if (act->gate.num_entries >= SPX5_PSFP_GCE_CNT) { >>> NL_SET_ERR_MSG_MOD(extack, "Invalid number of gate entries"); >>> return -EINVAL; >>> } >>> .. >>> sg->num_entries = act->gate.num_entries; >>> >>> So disable array-bounds as was done on gcc 11 and 12 > GCC 13 isn't released yet, and we've been working to make Linux warning-free under -Wareay-bounds. (And we succeeded briefly with GCC 11.) > > I'd much rather get GCC fixed. This is due to the shift sanitizer reducing the scope of num_entries (via macro args) to 0-31, which is still >4. This seems like a hinting bug in GCC: just because the variable was used in a shift doesn't mean the compiler can make any value assumptions. The build with fail generally with gcc 13. The warnings could be cleaned without having an error, but I looked at multiple errors, none of them were real. imo this is a broken compiler option. Tom > > -Kees > > >
On Tue, Mar 7, 2023 at 2:07 AM Tom Rix <trix@redhat.com> wrote: > > The build with fail generally with gcc 13. > > The warnings could be cleaned without having an error, but I looked at > multiple errors, none of them were real. > > imo this is a broken compiler option. I am not sure I understand -- my reading of Kees' message is that he would prefer to get the warning (rather than the kernel) fixed before GCC 13 releases. Are you asking to have the option disabled until GCC 13 releases and reevaluate then? How many warnings are you getting? Are those actual errors or `-Werror`? Cheers, Miguel
On 3/7/23 3:42 AM, Miguel Ojeda wrote: > On Tue, Mar 7, 2023 at 2:07 AM Tom Rix <trix@redhat.com> wrote: >> The build with fail generally with gcc 13. >> >> The warnings could be cleaned without having an error, but I looked at >> multiple errors, none of them were real. >> >> imo this is a broken compiler option. > I am not sure I understand -- my reading of Kees' message is that he > would prefer to get the warning (rather than the kernel) fixed before > GCC 13 releases. yes, that would be ideal. But anyone using gcc 13 in the meanwhile will have a broken build and any other aspect of testing the kernel with gcc 13 would have to be deferred to after the fix, if it happens. > > Are you asking to have the option disabled until GCC 13 releases and > reevaluate then? How many warnings are you getting? Are those actual > errors or `-Werror`? With W=1, there are 40 error:'s, sorry I do not have the default logs at hand. I looked about 10 of them over the weekend, they we all bogus. So gcc needs to be fixed first, just disabling with -Wnoerror will give folks bad problems that do not need fixing. I am asking that we at least temporarily disable this option so the build break is fixed. Tom > > Cheers, > Miguel >
diff --git a/init/Kconfig b/init/Kconfig index 1fb5f313d18f..10d0a0020726 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -898,10 +898,14 @@ config GCC11_NO_ARRAY_BOUNDS config GCC12_NO_ARRAY_BOUNDS def_bool y +config GCC13_NO_ARRAY_BOUNDS + def_bool y + config CC_NO_ARRAY_BOUNDS bool default y if CC_IS_GCC && GCC_VERSION >= 110000 && GCC_VERSION < 120000 && GCC11_NO_ARRAY_BOUNDS default y if CC_IS_GCC && GCC_VERSION >= 120000 && GCC_VERSION < 130000 && GCC12_NO_ARRAY_BOUNDS + default y if CC_IS_GCC && GCC_VERSION >= 130000 && GCC_VERSION < 140000 && GCC13_NO_ARRAY_BOUNDS # # For architectures that know their GCC __int128 support is sound