Message ID | 20230922172858.3822653-13-keescook@chromium.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp5852555vqi; Fri, 22 Sep 2023 13:37:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF/wPPMSNX7v4yF6eW40t1traiIXtwEQkqhdD/9p5fG0MLFRvc8e839WEz58CwbO8TfP3fj X-Received: by 2002:a05:6808:18a1:b0:3a7:83a7:ae71 with SMTP id bi33-20020a05680818a100b003a783a7ae71mr1025821oib.54.1695415052560; Fri, 22 Sep 2023 13:37:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695415052; cv=none; d=google.com; s=arc-20160816; b=l+61E5DdAfIIA3dsqAkS/2AQ80rSfJ/7p5iGoRlTPfIb5Lz87Ll6f15Opam35DOiUp eDwimcM6To60i5RntJMOinx1VydliBbJUhnEVEADAzDyEBrYshi9Fd5v69XuHDzU75oG j146+ujrdNGoCYCEUCzcOYupWZjfZY5Xp+71VobC6stWKCBStRM1vo6nZvqKU7J93v3Y MxhXxKdf16tdrRqFPAKnzCNzACxhz4fHKlceJHtH+v7bU/wXlux5iB3Y8BWG4ASv/9sA xQfnfJEPhBiCMhazF8RQ7O1Utp85JZ4Y0ezJmhHhBJpZfWMXZ9QN+k9/0Ye1Z1b82iOE 5JkA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=gSa6oULDCwttnYj/UXkUGWzp9s7+1yQ+R9ugGfGb1B4=; fh=+gjaOjUtCM2frIORyjUO4we5AR3ByLkf2z3mugthF4Q=; b=UMRbEvkATXksfEnT5EBYyoy4vChbIZc57utMA0wnGHCXUQo6uSFp1uST8Mwe0bpIKt z/W+KsTyUxdQgYa1Pxu4y+7UqdjSuanBCHNIgk6Ro/GY7ShkrCFRG24hq5GEAbBeZBLO ezdVeoLeNb6vOFizjeRQsCp+njSVVMMWJwyH0mV2DEG+L56xOPXXB/qFvdRpvwrhxuOI H3Dp9WfQwH8XYUYaSy/QVMnbQnGnlVqBRi2u9PbafEY3rCeDL9MmR54twIFmiJ5of51L MDRGp1rb+8DWIXJGToLvDqz11R1Aftt1tiinNvZX6m0mirTmfETXWVUVt3TZrO4ttcvg l93Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W12qSJ2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h2-20020a056a00230200b0068e390d86b4si4829321pfh.133.2023.09.22.13.37.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 13:37:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=W12qSJ2a; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ADBDC860AD33; Fri, 22 Sep 2023 10:29:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233293AbjIVR3y (ORCPT <rfc822;pwkd43@gmail.com> + 28 others); Fri, 22 Sep 2023 13:29:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233041AbjIVR3S (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 22 Sep 2023 13:29:18 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2BCDCE5 for <linux-kernel@vger.kernel.org>; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2765c9f2a39so1764923a91.0 for <linux-kernel@vger.kernel.org>; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695403749; x=1696008549; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gSa6oULDCwttnYj/UXkUGWzp9s7+1yQ+R9ugGfGb1B4=; b=W12qSJ2a5KmiFisUjHH7hkoQcfR59dH5U/g5DqfnK1X8qgWD7FJWHpvRjlyO3L06wD etWMl21Qgyl4m2ghvH16fNsvkac2IlGdqgg0iM/ab+qHVxMkbqYgbuJ+tjrVxBZ9Qede QVQcA9jLn2YqAKcTCwMx6gNG1lG2eObrAU6Sc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695403749; x=1696008549; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gSa6oULDCwttnYj/UXkUGWzp9s7+1yQ+R9ugGfGb1B4=; b=O+YQvBIn7W3Arq6RTjNzzLb6uV0d3y4wz6srq+tyIo6SfxJI87yClaw5olj6N/Unjo fxFxkTDqsWpbLlY8hD7ftIqXQFdD48yriixicrgQz3AmW3Mrpge+dK9ef4B5SxWjyFT7 HuCYsa/i9Q64xci5ucLIiNo9M1ni4NzVgNeqvIDumY3BBbKAiKIr8GKDiNG/ofn1bCi5 FXKIUXbdKtsXU+laYjt67Lopz+Kp0HrsK88MBwZpSyaY+E7lLpuWJPphXw/5Fs1KIcS7 oIy3dQev9NagOYF8pFm6y+GowJ4FnKP8NCmGO5+1kZ5I8t+enuLpvBblFOa1H55Y3ct6 9Nmg== X-Gm-Message-State: AOJu0YwUbE1b/Hkk/qbKC6oLNE3V+s5l+DGw+kVsF+PUZqjNHcpMElcM zrFW1Lgd8XXoDrj1aZP/snvfPA== X-Received: by 2002:a17:90b:1bc5:b0:277:1bd8:abe1 with SMTP id oa5-20020a17090b1bc500b002771bd8abe1mr303008pjb.30.1695403749534; Fri, 22 Sep 2023 10:29:09 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id 26-20020a17090a1a1a00b00276fc32c0dasm3068784pjk.4.2023.09.22.10.29.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:29:04 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: Jakub Kicinski <kuba@kernel.org> Cc: Kees Cook <keescook@chromium.org>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Paolo Abeni <pabeni@redhat.com>, Shaokun Zhang <zhangshaokun@hisilicon.com>, netdev@vger.kernel.org, linux-parisc@vger.kernel.org, Jamal Hadi Salim <jhs@mojatatu.com>, David Ahern <dsahern@kernel.org>, Martin KaFai Lau <martin.lau@kernel.org>, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Alexei Starovoitov <ast@kernel.org>, Yisen Zhuang <yisen.zhuang@huawei.com>, Salil Mehta <salil.mehta@huawei.com>, Claudiu Manoil <claudiu.manoil@nxp.com>, Vladimir Oltean <vladimir.oltean@nxp.com>, "K. Y. Srinivasan" <kys@microsoft.com>, Haiyang Zhang <haiyangz@microsoft.com>, Wei Liu <wei.liu@kernel.org>, Dexuan Cui <decui@microsoft.com>, Long Li <longli@microsoft.com>, Ajay Sharma <sharmaajay@microsoft.com>, Alex Elder <elder@kernel.org>, Pravin B Shelar <pshelar@ovn.org>, Cong Wang <xiyou.wangcong@gmail.com>, Jiri Pirko <jiri@resnulli.us>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Simon Horman <horms@kernel.org>, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-rdma@vger.kernel.org, dev@openvswitch.org, llvm@lists.linux.dev, linux-hardening@vger.kernel.org Subject: [PATCH 13/14] net: tulip: Annotate struct mediatable with __counted_by Date: Fri, 22 Sep 2023 10:28:55 -0700 Message-Id: <20230922172858.3822653-13-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230922172449.work.906-kees@kernel.org> References: <20230922172449.work.906-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1360; i=keescook@chromium.org; h=from:subject; bh=pEQ6m/Ojl8iZZMdU3eWLn6pX8bV9cI5eUZQsnPhAnjQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XkbXKZplSh9lbnY+7Kzc2rn8+8PrOJtg7N VYk6XUim8qJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JlK4D/0a5nvQxsfMMYe9Iz6FtaE4ytVsQDcsZFdGmgQChSwGLCdG1Sa3F9I/G5YpqxGxJ9MNkss +nBxQtIkxud0XXfvo7iopnxIgD4mvFFE82jWjI5l+YqV7TCu70N8lRiKrnPnHt7F4pX/YBRSzP4 Z4CSFFVLw4aHwapWBtYrbzgkkkOcawEXJ9SwIe5uQjCSi5cTm3Fhxi1Y3b3gnLG2UE19n3AAvV1 MELt6/MIMajh61Zk7bylLfR1U9tDOz34sjH3t6DRsGC34XAypF/4EZFJ3HpQHdnPPo0b1WJN+R9 I4X59+l8NGkwQHFOzJZS/jHa/7YBQAkymun70pKFQv4oEGS5anucsYwBt8F9W+lQ6it5Z8PWv4g nlHRBeEueC6LuAI+hB7sF6dD3LB/xaawEDJKiHZaHoG9CwxgxtXI+s9GBsAhetoUmE2b5GNdoEW Ix5esRXBd3MxDY2qQKgBHpxzkJCjVcBkSIDPfB+6QbvXKiugSApEqCw52zAoL4vZ1DIYTX+eULT aFDnk/QcBxCFto/Y/DDesSQa/0VZ+AkYXsY2Wo+QpAFR7HYoGmEub0VuATWQu8NsBJEZDh1tQ5N 1uU8WV2UjWnZfw75hLVF3Biggl8OKiurzRsCNrHh5yDeGQp0hufJgv+TSoR9JC2NZtc69JniRcJ Urav/CBb855RzPA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 22 Sep 2023 10:29:54 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777771534393677725 X-GMAIL-MSGID: 1777771534393677725 |
Series |
Batch 1: Annotate structs with __counted_by
|
|
Commit Message
Kees Cook
Sept. 22, 2023, 5:28 p.m. UTC
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS
(for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
As found with Coccinelle[1], add __counted_by for struct mediatable.
[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: netdev@vger.kernel.org
Cc: linux-parisc@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/net/ethernet/dec/tulip/tulip.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 9/22/23 11:28, Kees Cook wrote: > Prepare for the coming implementation by GCC and Clang of the __counted_by > attribute. Flexible array members annotated with __counted_by can have > their accesses bounds-checked at run-time checking via CONFIG_UBSAN_BOUNDS > (for array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family > functions). > > As found with Coccinelle[1], add __counted_by for struct mediatable. > > [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci > > Cc: "David S. Miller" <davem@davemloft.net> > Cc: Eric Dumazet <edumazet@google.com> > Cc: Jakub Kicinski <kuba@kernel.org> > Cc: Paolo Abeni <pabeni@redhat.com> > Cc: Shaokun Zhang <zhangshaokun@hisilicon.com> > Cc: netdev@vger.kernel.org > Cc: linux-parisc@vger.kernel.org > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks
diff --git a/drivers/net/ethernet/dec/tulip/tulip.h b/drivers/net/ethernet/dec/tulip/tulip.h index 0ed598dc7569..bd786dfbc066 100644 --- a/drivers/net/ethernet/dec/tulip/tulip.h +++ b/drivers/net/ethernet/dec/tulip/tulip.h @@ -381,7 +381,7 @@ struct mediatable { unsigned has_reset:6; u32 csr15dir; u32 csr15val; /* 21143 NWay setting. */ - struct medialeaf mleaf[]; + struct medialeaf mleaf[] __counted_by(leafcount); };