Message ID | 20231003231833.work.027-kees@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2a8e:b0:403:3b70:6f57 with SMTP id in14csp2409834vqb; Tue, 3 Oct 2023 16:19:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHBvbcRUQleUG9Wr/jUp1iS2tPSyaOYjIVlNpT7wZN5vSb1XudyRNIhHrj9zH2oZnoMa4BF X-Received: by 2002:a17:90b:4b42:b0:277:422d:3a0f with SMTP id mi2-20020a17090b4b4200b00277422d3a0fmr1027097pjb.17.1696375170671; Tue, 03 Oct 2023 16:19:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696375170; cv=none; d=google.com; s=arc-20160816; b=RRDiN55hG1mxUqOF3mvZh7ogTjBJpzLRU+r+8ru8MU84Y4q3MTWz4x6qwFHz0KxDd8 sQp3ml5/E+I/K8f9oWrtiNkBIH/eAeieDvTZYjARmKD3t8qrI8KREfDV0j0hP4f7uIh+ dE+7aLTZmuEQDzpgyzmumLBsbDHhRfyhv8GjSL9bObU2tH21el1AMnXFgvkyRvaeVYG9 sLmMrDjyfXdghMKnJHH3zAAmv1r+jzAD1D8a34YMyRcYxmaWU06C2Ek0rI3ByeNA3cz5 QyDu6FKnc5fQxIPQIhUCtLzDKl61OcsLgbdYoY0YwIs9IPf3lqBw492p+PEIVdAenRt4 FfEg== 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=Cs/y+xaFiHWEOz6Orvy1iq9h94Wx2pdzVIF/nLH5ouQ=; fh=n9qbzr/cYwdKcwqWpNnmjHfsR7+sLjq6s0nsIEQwGk0=; b=QncuSCKXRX8BVELn8fo6Amt4wAzrcMKxZWt69Qje5G8MAK5NKe0gLm1DgPebTlK4Em gSDltJ6WE9FB8tezJml1QxGarhBe2FcloA1w0FrfnU2n+zMNxGcU/ULCs+SSJjNzncWv iIP+l8DsWyJWBMB7dhcvAqop0ZC3rRd1axJCdxC1F/6BHlIXMHD+B5qNuqV6qXixmY3e mKCwg7mf9kFLZ0OUHDSup+CvwgmQyV7GjNkay6jESoQnG7J4PUebF7I31I7XV5lLNyJg 0rvBoe6rn9LQYe9N4Xpd0l5K7ODAV0kICiNJA8lEFtG5NBWx1GXk9NSQbCPyIgo4lu16 rjBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=of9zwq4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id mi10-20020a17090b4b4a00b0027921228848si299391pjb.133.2023.10.03.16.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:19:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=of9zwq4s; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id 1B2578197063; Tue, 3 Oct 2023 16:19:28 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234975AbjJCXSs (ORCPT <rfc822;chrisfriedt@gmail.com> + 17 others); Tue, 3 Oct 2023 19:18:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234908AbjJCXSp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 3 Oct 2023 19:18:45 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0F727C9 for <linux-kernel@vger.kernel.org>; Tue, 3 Oct 2023 16:18:37 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1c60f1a2652so2891695ad.0 for <linux-kernel@vger.kernel.org>; Tue, 03 Oct 2023 16:18:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696375116; x=1696979916; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Cs/y+xaFiHWEOz6Orvy1iq9h94Wx2pdzVIF/nLH5ouQ=; b=of9zwq4so6JvnrmFQXDJe7dWqOSRgSSDWZQRgZKmRK51JJyEvkIDT8bUtmUHRElqiQ g+mGTqFnsfhmGD0y3ZzdKjDTmifhuzWzBdOFZlDGKsy1u3VlkUWsnux0PBBQGKhkktPk rCMNkpPlU+o6Drn894KU7APOs9RYLpPAvmNVk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696375116; x=1696979916; 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=Cs/y+xaFiHWEOz6Orvy1iq9h94Wx2pdzVIF/nLH5ouQ=; b=LRh8YslWUdXhyvSjpjzhYW2FGJkpbIOr6k77ntM40NWtZbTLzpQVv152Lmr/3KLZJ8 ObPTvG/2O2rKmdDzHV/MjVh3eCLUZetLiZFoEuB+ceqxXIzWWWeVv4Nqmm33+WYeg5YS gY24Kg0s2b2NaL5FFD7xVP3Y7BYUXCI8ATyuzq3scNB6txJtEyK1cjR4x9t+tUNt9q0A vpGy78mNMQWBapmfujQHy4/UkX0PEW5fLoSmpBidVsaAp8lP9PHV5MyaWbz1Opr0iqvI K9W2Ed98qdYOfFE254a2R5oPbEvsRtAPrMnTiacnaRwfDbcT+5HLYGjopOmTA30FddlI W+PQ== X-Gm-Message-State: AOJu0YxYH2GDOp7lNcvlaz9DYFEtsrv+eHr7EqtZ2hNSxoZsge1gWLtY Qfw0jN0Rrl34aj6XRgZ1Nm64Xw== X-Received: by 2002:a17:902:db86:b0:1c3:e5bf:a9fe with SMTP id m6-20020a170902db8600b001c3e5bfa9femr886524pld.30.1696375116475; Tue, 03 Oct 2023 16:18:36 -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 t12-20020a1709028c8c00b001b89466a5f4sm2192072plo.105.2023.10.03.16.18.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Oct 2023 16:18:36 -0700 (PDT) From: Kees Cook <keescook@chromium.org> To: "David S. Miller" <davem@davemloft.net> Cc: Kees Cook <keescook@chromium.org>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, netdev@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, llvm@lists.linux.dev Subject: [PATCH] flow_offload: Annotate struct flow_action_entry with __counted_by Date: Tue, 3 Oct 2023 16:18:33 -0700 Message-Id: <20231003231833.work.027-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1296; i=keescook@chromium.org; h=from:subject:message-id; bh=0boqWAsd/6ZiDm6IubJhgrIAyAV2i1CalHaJrRP30Sg=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlHKFJjLDxYFWAIlzLyPwWgmZ9hiaj7VEOr2oHY k08COfXcdCJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRyhSQAKCRCJcvTf3G3A JrK8D/9KEPYj/M8bXAiIzxWF2ZyJR84xb9ciEEfjEjN2R4UHdjtchwNrtasquYrt3ny+WIGBbhe 0JtnoSkCuYrCzaTNpFQpAVzcKZMYAWOoTfq8XhRw2t8wwKrsiTpXgFd03LDFVgqgqamzoOXwyCi VIsbY5R7xwYN9QoafMgKzwFlNt0gNdb0JALM9kFi1qxxKVXJKh7hJB6BepurEVM9/3t3qR/AeqX 2Xp5re530r88nPiId+lrJucvtIiZGC+EWjgwcMP9ZLg3sIdrmtXVDqeEXTLl9cSRMVnlPLRyk9o BVFl6eI3bjvpX9XG1Hk7XEk9UkjIOvK5d7ybgYiQIELVfYgt3SM19+jQFcg0opDFiTiFTVLeOSr RZ62m/4MMT+blNcje0k+2kr0KBdkZ2QPN1yBuvvQUQGiEOiAst/XtSRQRzcurQnB71jd7rvzbhY 8mK+AXpzzX6mSSquLFzpQYS/DNsfZuda9IyoJ4cBNa/aC6Lll7qGFFJIhu7waaUmJ4GD7u/WE0i hYaMBUWBon4+wbtKUUgLqI8HJhyNfxSoXaA1JwhKA7liruJEb7wSadoNZKL51HpVQgvv6mNShDe oWrRx5uLCPSPzgKjEhQIHY8foSPVBmtvbRWzmEenClfkDY4KC6Y3KelbIByzdKscBCONl9tL/9+ XLbpVM1 KEBl5urw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email 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 (agentk.vger.email [0.0.0.0]); Tue, 03 Oct 2023 16:19:28 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778778291348981564 X-GMAIL-MSGID: 1778778291348981564 |
Series |
flow_offload: Annotate struct flow_action_entry with __counted_by
|
|
Commit Message
Kees Cook
Oct. 3, 2023, 11:18 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 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 flow_action_entry.
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: netdev@vger.kernel.org
Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1]
Signed-off-by: Kees Cook <keescook@chromium.org>
---
include/net/flow_offload.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 10/4/23 01:18, 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 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 flow_action_entry. > > 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: netdev@vger.kernel.org > Link: https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci [1] > Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks -- Gustavo > --- > include/net/flow_offload.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h > index 9efa9a59e81f..314087a5e181 100644 > --- a/include/net/flow_offload.h > +++ b/include/net/flow_offload.h > @@ -333,7 +333,7 @@ struct flow_action_entry { > > struct flow_action { > unsigned int num_entries; > - struct flow_action_entry entries[]; > + struct flow_action_entry entries[] __counted_by(num_entries); > }; > > static inline bool flow_action_has_entries(const struct flow_action *action)
Hello: This patch was applied to netdev/net-next.git (main) by David S. Miller <davem@davemloft.net>: On Tue, 3 Oct 2023 16:18:33 -0700 you 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 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 flow_action_entry. > > [...] Here is the summary with links: - flow_offload: Annotate struct flow_action_entry with __counted_by https://git.kernel.org/netdev/net-next/c/99474727d5d5 You are awesome, thank you!
diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h index 9efa9a59e81f..314087a5e181 100644 --- a/include/net/flow_offload.h +++ b/include/net/flow_offload.h @@ -333,7 +333,7 @@ struct flow_action_entry { struct flow_action { unsigned int num_entries; - struct flow_action_entry entries[]; + struct flow_action_entry entries[] __counted_by(num_entries); }; static inline bool flow_action_has_entries(const struct flow_action *action)