From patchwork Fri Sep 22 17:28:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 143649 Return-Path: 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 + 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 ); 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 ; Fri, 22 Sep 2023 10:29:10 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id 98e67ed59e1d1-2765c9f2a39so1764923a91.0 for ; 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 To: Jakub Kicinski Cc: Kees Cook , "David S. Miller" , Eric Dumazet , Paolo Abeni , Shaokun Zhang , netdev@vger.kernel.org, linux-parisc@vger.kernel.org, Jamal Hadi Salim , David Ahern , Martin KaFai Lau , "Gustavo A. R. Silva" , Alexei Starovoitov , Yisen Zhuang , Salil Mehta , Claudiu Manoil , Vladimir Oltean , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Ajay Sharma , Alex Elder , Pravin B Shelar , Cong Wang , Jiri Pirko , Nathan Chancellor , Nick Desaulniers , Tom Rix , Simon Horman , 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 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: 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 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" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: Shaokun Zhang Cc: netdev@vger.kernel.org Cc: linux-parisc@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/net/ethernet/dec/tulip/tulip.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); };