From patchwork Fri Sep 22 17:28:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 1838409 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Y2H20tIb; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=patchwork.ozlabs.org) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Rsfbk3Wz5z1ynH for ; Sat, 23 Sep 2023 03:37:22 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 4B86481E2A; Fri, 22 Sep 2023 17:37:20 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4B86481E2A Authentication-Results: smtp1.osuosl.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Y2H20tIb X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id oiyVrghs9tjB; Fri, 22 Sep 2023 17:37:19 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4B2B6814C9; Fri, 22 Sep 2023 17:37:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4B2B6814C9 Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 19B6EC0071; Fri, 22 Sep 2023 17:37:18 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 91FA8C0032 for ; Fri, 22 Sep 2023 17:37:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 600FA4197F for ; Fri, 22 Sep 2023 17:37:16 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 600FA4197F Authentication-Results: smtp2.osuosl.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=Y2H20tIb X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uq2mRoivSlWP for ; Fri, 22 Sep 2023 17:37:15 +0000 (UTC) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by smtp2.osuosl.org (Postfix) with ESMTPS id 3810140B56 for ; Fri, 22 Sep 2023 17:37:15 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 3810140B56 Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c5dd017b30so17085605ad.0 for ; Fri, 22 Sep 2023 10:37:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695404234; x=1696009034; darn=openvswitch.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=aHy2jcM546mf5Nw3NjJJcdsZQ6G2F/rbr9BMeebO220=; b=Y2H20tIbQYPlyYUAfEMSHFn5fo0Dz2XFWAAqV+VJFbKaHcwt4TTr61MreReix4o1yd dJpnqo0zDl/gwilfTyk5PePY6mh4yFcrkfPN30LHNVKpn0/Zuv1jvskUC8BoDod+1a2B cwyje+AkhjVDkfQ1B8JNgaoXfTyXy4BXfUXBI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695404234; x=1696009034; 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=aHy2jcM546mf5Nw3NjJJcdsZQ6G2F/rbr9BMeebO220=; b=iTXhPtdSsA9JqoEFpAXV5VmtlQToV+Z2IERfAU7ab8g6Rr07B/eZHeQ/0PbfBEWgRz SK+a2Hp1jSqfItoch/amowiM2NlPxzD2qSumohdaUaQBteP6rVEwpAspNItcuTmKKfoq V/FVzXCJ+/UvBXuqUpbUnCS7iu1VxFodTnlewS4S1iZ7pKOMGBrZZteYZvwKmij8NKk6 7Lv4hQWht0Ez1Urg+dUGPN1QjOTpkB/O4JsKqhpUxW0Fa9oKtqEnQ2ILXL5WDYc86XXh rN6+KoLI2dF/W8MtyYbtFomiH0oJHdBpSwEg3RdkQq5Rc3Nr8zqzkbBK/jgzCOb3b78S PsNA== X-Gm-Message-State: AOJu0YzcuqtkuNpNOsBrRYhrubzei8cjJ26IwcUJqd4PEsijoOZCHtOI AOdov40FVRJobvgli0IWXqzIIQ== X-Google-Smtp-Source: AGHT+IForaNfEngbgYzLn0XvlHSaSBMfd2+hDVPVDP0+7yMW2kQR3T0MzlrjAe6sTlVW6GLIrm0kZg== X-Received: by 2002:a17:902:dac1:b0:1c3:e4b8:701f with SMTP id q1-20020a170902dac100b001c3e4b8701fmr479521plx.19.1695404234658; Fri, 22 Sep 2023 10:37:14 -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 g7-20020a1709029f8700b001b694140d96sm3771126plq.170.2023.09.22.10.37.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 10:37:14 -0700 (PDT) From: Kees Cook To: Jakub Kicinski Date: Fri, 22 Sep 2023 10:28:53 -0700 Message-Id: <20230922172858.3822653-11-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=1477; i=keescook@chromium.org; h=from:subject; bh=UT1ZdosG6thsQKbZuWlvvKtNoMV5v4P0vRQDHVv6AlQ=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlDc7XSQgN5HFuzDmTQh0kuKGN8VvhxLvLNcFeh bt51QZ4mKKJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZQ3O1wAKCRCJcvTf3G3A JqYjD/9GzxaHc4IrVjUkBj5/d8FeY4MZoAp8KPJKCM4E/stoQ89RWnkxPvXs2ub51LtTAM7Q8Nq 952ZRLOpGoccIMFSjcVlpFYlDEZRIMMkg06PGDQs8BLBgRp2Xbo/GI6r0attHGC5ruXY6R1djKy TJbXDQFFgVuUfCE3ZiMZG1SgrWkLCsxTlZFBeXY5+pEEWOp6EaAQULbpmh8/N9D4gZE1/vQgF0E 0nrtThbucWqOv2lWVWoESP8KBQ2hbiP04yjKp5QhnvG9ai5TJ7czKEGFFzfw+6WlMuj3ohAC+V8 eRoArmKj5/q8DXUTMOGzNsFBobqrSbgfMk+Fu+dvyK+gxTw1urL7a54Rms23bLytd1W3qsH4TdV MjqSkdW0hShdhKqJxvRMw9H0OSSv2T/191tK8eFarSmolgQCBqQkjQN3HORH8VsB7NK8Rls+AZZ ZNO99qTOvddCRUmOlsJli6YplJtOWudvU5OVaGivwWMqWzCqGnASdsSFHSQlyO0vGgy05UCTaTk OlgQNwhDSjtZX7ZovqyZY56wRJXHkVTd8P76Qi0s1d5yI9hxyzGrFnUmCrlF0P8oGHQIJh9h+HQ 9WKEJyCgyiKmb4+eBOVQnfxP063FQtmEVJl/nVl8B4+NKlYVWjZ0PUztJwDm4Ir6xg+DibLIp2O wM3jkIQFKhrIJvA== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Cc: linux-hyperv@vger.kernel.org, Vladimir Oltean , llvm@lists.linux.dev, Alexei Starovoitov , linux-kernel@vger.kernel.org, Eric Dumazet , linux-hardening@vger.kernel.org, "K. Y. Srinivasan" , Martin KaFai Lau , dev@openvswitch.org, Wei Liu , linux-rdma@vger.kernel.org, Long Li , Dexuan Cui , Tom Rix , Paolo Abeni , Yisen Zhuang , Ajay Sharma , Jiri Pirko , Kees Cook , Haiyang Zhang , Jamal Hadi Salim , Shaokun Zhang , Claudiu Manoil , Cong Wang , Nathan Chancellor , Salil Mehta , Alex Elder , linux-parisc@vger.kernel.org, netdev@vger.kernel.org, David Ahern , Nick Desaulniers , "Gustavo A. R. Silva" , Simon Horman , "David S. Miller" Subject: [ovs-dev] [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate with __counted_by X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" 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 enetc_psfp_gate. [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci Cc: Claudiu Manoil Cc: Vladimir Oltean Cc: "David S. Miller" Cc: Eric Dumazet Cc: Jakub Kicinski Cc: Paolo Abeni Cc: netdev@vger.kernel.org Signed-off-by: Kees Cook Reviewed-by: Gustavo A. R. Silva --- drivers/net/ethernet/freescale/enetc/enetc_qos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_qos.c b/drivers/net/ethernet/freescale/enetc/enetc_qos.c index 2513b44056c1..b65da49dd926 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_qos.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_qos.c @@ -443,7 +443,7 @@ struct enetc_psfp_gate { u32 num_entries; refcount_t refcount; struct hlist_node node; - struct action_gate_entry entries[]; + struct action_gate_entry entries[] __counted_by(num_entries); }; /* Only enable the green color frame now