linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 00/14] Batch 1: Annotate structs with __counted_by
@ 2023-09-22 17:28 Kees Cook
  2023-09-22 17:28 ` [PATCH 01/14] ipv4: Annotate struct fib_info " Kees Cook
                   ` (15 more replies)
  0 siblings, 16 replies; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Jamal Hadi Salim, David S. Miller, David Ahern,
	Eric Dumazet, Paolo Abeni, 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,
	Shaokun Zhang, Cong Wang, Jiri Pirko, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel, netdev,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

Hi,

This is the batch 1 of patches touching netdev for preparing 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 to structs that would
benefit from the annotation.

Since the element count member must be set before accessing the annotated
flexible array member, some patches also move the member's initialization
earlier. (These are noted in the individual patches.)

-Kees

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci


Kees Cook (14):
  ipv4: Annotate struct fib_info with __counted_by
  ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by
  ipv6: Annotate struct ip6_sf_socklist with __counted_by
  net: hns: Annotate struct ppe_common_cb with __counted_by
  net: enetc: Annotate struct enetc_int_vector with __counted_by
  net: hisilicon: Annotate struct rcb_common_cb with __counted_by
  net: mana: Annotate struct mana_rxq with __counted_by
  net: ipa: Annotate struct ipa_power with __counted_by
  net: mana: Annotate struct hwc_dma_buf with __counted_by
  net: openvswitch: Annotate struct dp_meter_instance with __counted_by
  net: enetc: Annotate struct enetc_psfp_gate with __counted_by
  net: openvswitch: Annotate struct dp_meter with __counted_by
  net: tulip: Annotate struct mediatable with __counted_by
  net: sched: Annotate struct tc_pedit with __counted_by

 drivers/net/ethernet/dec/tulip/tulip.h            | 2 +-
 drivers/net/ethernet/freescale/enetc/enetc.h      | 2 +-
 drivers/net/ethernet/freescale/enetc/enetc_qos.c  | 2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 2 +-
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
 drivers/net/ipa/ipa_power.c                       | 2 +-
 include/linux/igmp.h                              | 2 +-
 include/net/if_inet6.h                            | 2 +-
 include/net/ip_fib.h                              | 2 +-
 include/net/mana/hw_channel.h                     | 2 +-
 include/net/mana/mana.h                           | 2 +-
 net/openvswitch/meter.h                           | 4 ++--
 net/sched/act_pedit.c                             | 2 +-
 13 files changed, 14 insertions(+), 14 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 37+ messages in thread

* [PATCH 01/14] ipv4: Annotate struct fib_info with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:43   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 02/14] ipv4/igmp: Annotate struct ip_sf_socklist " Kees Cook
                   ` (14 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, David S. Miller, David Ahern, Eric Dumazet,
	Paolo Abeni, netdev, Jamal Hadi Salim, 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, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, linux-hyperv, linux-rdma, dev,
	linux-parisc, llvm, linux-hardening

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 fib_info.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: "David S. Miller" <davem@davemloft.net>
Cc: David Ahern <dsahern@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/net/ip_fib.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
index f0c13864180e..84b0a82c9df4 100644
--- a/include/net/ip_fib.h
+++ b/include/net/ip_fib.h
@@ -156,7 +156,7 @@ struct fib_info {
 	bool			nh_updated;
 	struct nexthop		*nh;
 	struct rcu_head		rcu;
-	struct fib_nh		fib_nh[];
+	struct fib_nh		fib_nh[] __counted_by(fib_nhs);
 };
 
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 02/14] ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
  2023-09-22 17:28 ` [PATCH 01/14] ipv4: Annotate struct fib_info " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:50   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 03/14] ipv6: Annotate struct ip6_sf_socklist " Kees Cook
                   ` (13 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, David S. Miller, Martin KaFai Lau,
	Gustavo A. R. Silva, Eric Dumazet, Alexei Starovoitov,
	Jamal Hadi Salim, David Ahern, Paolo Abeni, 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, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, netdev, linux-hyperv, linux-rdma,
	dev, linux-parisc, llvm, linux-hardening

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 ip_sf_socklist.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Martin KaFai Lau <martin.lau@kernel.org>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Alexei Starovoitov <ast@kernel.org>
Cc: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/linux/igmp.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/igmp.h b/include/linux/igmp.h
index ebf4349a53af..5171231f70a8 100644
--- a/include/linux/igmp.h
+++ b/include/linux/igmp.h
@@ -39,7 +39,7 @@ struct ip_sf_socklist {
 	unsigned int		sl_max;
 	unsigned int		sl_count;
 	struct rcu_head		rcu;
-	__be32			sl_addr[];
+	__be32			sl_addr[] __counted_by(sl_max);
 };
 
 #define IP_SFBLOCK	10	/* allocate this many at once */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 03/14] ipv6: Annotate struct ip6_sf_socklist with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
  2023-09-22 17:28 ` [PATCH 01/14] ipv4: Annotate struct fib_info " Kees Cook
  2023-09-22 17:28 ` [PATCH 02/14] ipv4/igmp: Annotate struct ip_sf_socklist " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:51   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 04/14] net: hns: Annotate struct ppe_common_cb " Kees Cook
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, David S. Miller, Eric Dumazet, Paolo Abeni, netdev,
	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, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, linux-hyperv, linux-rdma, dev,
	linux-parisc, llvm, linux-hardening

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 ip6_sf_socklist.

[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: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/net/if_inet6.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
index c8490729b4ae..3e454c4d7ba6 100644
--- a/include/net/if_inet6.h
+++ b/include/net/if_inet6.h
@@ -89,7 +89,7 @@ struct ip6_sf_socklist {
 	unsigned int		sl_max;
 	unsigned int		sl_count;
 	struct rcu_head		rcu;
-	struct in6_addr		sl_addr[];
+	struct in6_addr		sl_addr[] __counted_by(sl_max);
 };
 
 #define IP6_SFBLOCK	10	/* allocate this many at once */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 04/14] net: hns: Annotate struct ppe_common_cb with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (2 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 03/14] ipv6: Annotate struct ip6_sf_socklist " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:51   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 05/14] net: enetc: Annotate struct enetc_int_vector " Kees Cook
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Yisen Zhuang, Salil Mehta, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Claudiu Manoil, Vladimir Oltean, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

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 ppe_common_cb.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: Salil Mehta <salil.mehta@huawei.com>
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
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h
index 0f0e16f9afc0..7e00231c1acf 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h
@@ -92,7 +92,7 @@ struct ppe_common_cb {
 	u8 comm_index;   /*ppe_common index*/
 
 	u32 ppe_num;
-	struct hns_ppe_cb ppe_cb[];
+	struct hns_ppe_cb ppe_cb[] __counted_by(ppe_num);
 
 };
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 05/14] net: enetc: Annotate struct enetc_int_vector with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (3 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 04/14] net: hns: Annotate struct ppe_common_cb " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:52   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 06/14] net: hisilicon: Annotate struct rcb_common_cb " Kees Cook
                   ` (10 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Claudiu Manoil, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

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_int_vector.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Claudiu Manoil <claudiu.manoil@nxp.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
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
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/ethernet/freescale/enetc/enetc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
index 7439739cd81a..a9c2ff22431c 100644
--- a/drivers/net/ethernet/freescale/enetc/enetc.h
+++ b/drivers/net/ethernet/freescale/enetc/enetc.h
@@ -297,7 +297,7 @@ struct enetc_int_vector {
 	char name[ENETC_INT_NAME_MAX];
 
 	struct enetc_bdr rx_ring;
-	struct enetc_bdr tx_ring[];
+	struct enetc_bdr tx_ring[] __counted_by(count_tx_rings);
 } ____cacheline_aligned_in_smp;
 
 struct enetc_cls_rule {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 06/14] net: hisilicon: Annotate struct rcb_common_cb with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (4 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 05/14] net: enetc: Annotate struct enetc_int_vector " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:52   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 07/14] net: mana: Annotate struct mana_rxq " Kees Cook
                   ` (9 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Yisen Zhuang, Salil Mehta, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Claudiu Manoil, Vladimir Oltean, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

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 rcb_common_cb.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
Cc: Salil Mehta <salil.mehta@huawei.com>
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
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
index a9f805925699..c1e9b6997853 100644
--- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
+++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
@@ -108,7 +108,7 @@ struct rcb_common_cb {
 	u32 ring_num;
 	u32 desc_num; /*  desc num per queue*/
 
-	struct ring_pair_cb ring_pair_cb[];
+	struct ring_pair_cb ring_pair_cb[] __counted_by(ring_num);
 };
 
 int hns_rcb_buf_size2type(u32 buf_size);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 07/14] net: mana: Annotate struct mana_rxq with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (5 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 06/14] net: hisilicon: Annotate struct rcb_common_cb " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:55   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 08/14] net: ipa: Annotate struct ipa_power " Kees Cook
                   ` (8 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui,
	Long Li, Ajay Sharma, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-hyperv, linux-rdma, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, Claudiu Manoil, Vladimir Oltean,
	Alex Elder, Pravin B Shelar, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, dev, linux-parisc, llvm,
	linux-hardening

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 mana_rxq.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Dexuan Cui <decui@microsoft.com>
Cc: Long Li <longli@microsoft.com>
Cc: Ajay Sharma <sharmaajay@microsoft.com>
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: linux-hyperv@vger.kernel.org
Cc: linux-rdma@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/net/mana/mana.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
index 9f70b4332238..38441be68592 100644
--- a/include/net/mana/mana.h
+++ b/include/net/mana/mana.h
@@ -338,7 +338,7 @@ struct mana_rxq {
 	/* MUST BE THE LAST MEMBER:
 	 * Each receive buffer has an associated mana_recv_buf_oob.
 	 */
-	struct mana_recv_buf_oob rx_oobs[];
+	struct mana_recv_buf_oob rx_oobs[] __counted_by(num_rx_buf);
 };
 
 struct mana_tx_qp {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 08/14] net: ipa: Annotate struct ipa_power with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (6 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 07/14] net: mana: Annotate struct mana_rxq " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:55   ` Gustavo A. R. Silva
  2023-09-23 12:09   ` Alex Elder
  2023-09-22 17:28 ` [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf " Kees Cook
                   ` (7 subsequent siblings)
  15 siblings, 2 replies; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Alex Elder, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, 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, Pravin B Shelar, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, linux-hyperv, linux-rdma, dev,
	linux-parisc, llvm, linux-hardening

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 ipa_power.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Alex Elder <elder@kernel.org>
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
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 drivers/net/ipa/ipa_power.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
index 0eaa7a7f3343..e223886123ce 100644
--- a/drivers/net/ipa/ipa_power.c
+++ b/drivers/net/ipa/ipa_power.c
@@ -67,7 +67,7 @@ struct ipa_power {
 	spinlock_t spinlock;	/* used with STOPPED/STARTED power flags */
 	DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT);
 	u32 interconnect_count;
-	struct icc_bulk_data interconnect[];
+	struct icc_bulk_data interconnect[] __counted_by(interconnect_count);
 };
 
 /* Initialize interconnects required for IPA operation */
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (7 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 08/14] net: ipa: Annotate struct ipa_power " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:56   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance " Kees Cook
                   ` (6 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Long Li, Ajay Sharma, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-rdma, linux-hyperv, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, Claudiu Manoil, Vladimir Oltean,
	Alex Elder, Pravin B Shelar, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, dev, linux-parisc, llvm,
	linux-hardening

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 hwc_dma_buf.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Long Li <longli@microsoft.com>
Cc: Ajay Sharma <sharmaajay@microsoft.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Cc: Wei Liu <wei.liu@kernel.org>
Cc: Dexuan Cui <decui@microsoft.com>
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: linux-rdma@vger.kernel.org
Cc: linux-hyperv@vger.kernel.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 include/net/mana/hw_channel.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h
index 3d3b5c881bc1..158b125692c2 100644
--- a/include/net/mana/hw_channel.h
+++ b/include/net/mana/hw_channel.h
@@ -121,7 +121,7 @@ struct hwc_dma_buf {
 	u32 gpa_mkey;
 
 	u32 num_reqs;
-	struct hwc_work_request reqs[];
+	struct hwc_work_request reqs[] __counted_by(num_reqs);
 };
 
 typedef void hwc_rx_event_handler_t(void *ctx, u32 gdma_rxq_id,
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (8 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:56   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate " Kees Cook
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Pravin B Shelar, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, dev, 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, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, linux-parisc, llvm,
	linux-hardening

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 dp_meter_instance.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Pravin B Shelar <pshelar@ovn.org>
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
Cc: dev@openvswitch.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 net/openvswitch/meter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/meter.h b/net/openvswitch/meter.h
index 0c33889a8515..013de694221f 100644
--- a/net/openvswitch/meter.h
+++ b/net/openvswitch/meter.h
@@ -45,7 +45,7 @@ struct dp_meter {
 struct dp_meter_instance {
 	struct rcu_head rcu;
 	u32 n_meters;
-	struct dp_meter __rcu *dp_meters[];
+	struct dp_meter __rcu *dp_meters[] __counted_by(n_meters);
 };
 
 struct dp_meter_table {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (9 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:56   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 12/14] net: openvswitch: Annotate struct dp_meter " Kees Cook
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Claudiu Manoil, Vladimir Oltean, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

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 <claudiu.manoil@nxp.com>
Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
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
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 12/14] net: openvswitch: Annotate struct dp_meter with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (10 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:57   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 13/14] net: tulip: Annotate struct mediatable " Kees Cook
                   ` (3 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Pravin B Shelar, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, dev, 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, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, linux-parisc, llvm,
	linux-hardening

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 dp_meter.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Pravin B Shelar <pshelar@ovn.org>
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
Cc: dev@openvswitch.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 net/openvswitch/meter.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/meter.h b/net/openvswitch/meter.h
index 013de694221f..ed11cd12b512 100644
--- a/net/openvswitch/meter.h
+++ b/net/openvswitch/meter.h
@@ -39,7 +39,7 @@ struct dp_meter {
 	u32 max_delta_t;
 	u64 used;
 	struct ovs_flow_stats stats;
-	struct dp_meter_band bands[];
+	struct dp_meter_band bands[] __counted_by(n_bands);
 };
 
 struct dp_meter_instance {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 13/14] net: tulip: Annotate struct mediatable with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (11 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 12/14] net: openvswitch: Annotate struct dp_meter " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-23  1:57   ` Gustavo A. R. Silva
  2023-09-22 17:28 ` [PATCH 14/14] net: sched: Annotate struct tc_pedit " Kees Cook
                   ` (2 subsequent siblings)
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, David S. Miller, Eric Dumazet, Paolo Abeni,
	Shaokun Zhang, netdev, linux-parisc, 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, linux-hyperv, linux-rdma,
	dev, llvm, linux-hardening

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(-)

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);
 };
 
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* [PATCH 14/14] net: sched: Annotate struct tc_pedit with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (12 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 13/14] net: tulip: Annotate struct mediatable " Kees Cook
@ 2023-09-22 17:28 ` Kees Cook
  2023-09-22 18:18   ` Kees Cook
                     ` (2 more replies)
  2023-09-27 15:57 ` [PATCH 00/14] Batch 1: Annotate structs " Kees Cook
  2023-10-02 18:40 ` patchwork-bot+netdevbpf
  15 siblings, 3 replies; 37+ messages in thread
From: Kees Cook @ 2023-09-22 17:28 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Kees Cook, Jamal Hadi Salim, Cong Wang, Jiri Pirko,
	David S. Miller, Eric Dumazet, Paolo Abeni, netdev, 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, Shaokun Zhang,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

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 tc_pedit.
Additionally, since the element count member must be set before accessing
the annotated flexible array member, move its initialization earlier.

[1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci

Cc: Jamal Hadi Salim <jhs@mojatatu.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>
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
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 net/sched/act_pedit.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
index 1ef8fcfa9997..77c407eff3b0 100644
--- a/net/sched/act_pedit.c
+++ b/net/sched/act_pedit.c
@@ -515,11 +515,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
 		spin_unlock_bh(&p->tcf_lock);
 		return -ENOBUFS;
 	}
+	opt->nkeys = parms->tcfp_nkeys;
 
 	memcpy(opt->keys, parms->tcfp_keys,
 	       flex_array_size(opt, keys, parms->tcfp_nkeys));
 	opt->index = p->tcf_index;
-	opt->nkeys = parms->tcfp_nkeys;
 	opt->flags = parms->tcfp_flags;
 	opt->action = p->tcf_action;
 	opt->refcnt = refcount_read(&p->tcf_refcnt) - ref;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 37+ messages in thread

* Re: [PATCH 14/14] net: sched: Annotate struct tc_pedit with __counted_by
  2023-09-22 17:28 ` [PATCH 14/14] net: sched: Annotate struct tc_pedit " Kees Cook
@ 2023-09-22 18:18   ` Kees Cook
  2023-09-22 18:23   ` Kees Cook
  2023-09-23  2:06   ` Gustavo A. R. Silva
  2 siblings, 0 replies; 37+ messages in thread
From: Kees Cook @ 2023-09-22 18:18 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, 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, Shaokun Zhang, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

On Fri, Sep 22, 2023 at 10:28:56AM -0700, 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 tc_pedit.
> Additionally, since the element count member must be set before accessing
> the annotated flexible array member, move its initialization earlier.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  net/sched/act_pedit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index 1ef8fcfa9997..77c407eff3b0 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -515,11 +515,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
>  		spin_unlock_bh(&p->tcf_lock);
>  		return -ENOBUFS;
>  	}
> +	opt->nkeys = parms->tcfp_nkeys;
>  
>  	memcpy(opt->keys, parms->tcfp_keys,
>  	       flex_array_size(opt, keys, parms->tcfp_nkeys));
>  	opt->index = p->tcf_index;
> -	opt->nkeys = parms->tcfp_nkeys;
>  	opt->flags = parms->tcfp_flags;
>  	opt->action = p->tcf_action;
>  	opt->refcnt = refcount_read(&p->tcf_refcnt) - ref;
> -- 
> 2.34.1

Gustavo pointed out that the annotation half of this patch in missing.
My mistake! I will figure out where it went. :P Ah, the joys of
splitting up a treewide patch series...

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 14/14] net: sched: Annotate struct tc_pedit with __counted_by
  2023-09-22 17:28 ` [PATCH 14/14] net: sched: Annotate struct tc_pedit " Kees Cook
  2023-09-22 18:18   ` Kees Cook
@ 2023-09-22 18:23   ` Kees Cook
  2023-09-23  2:06   ` Gustavo A. R. Silva
  2 siblings, 0 replies; 37+ messages in thread
From: Kees Cook @ 2023-09-22 18:23 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, 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, Shaokun Zhang, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

On Fri, Sep 22, 2023 at 10:28:56AM -0700, 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 tc_pedit.
> Additionally, since the element count member must be set before accessing
> the annotated flexible array member, move its initialization earlier.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>  net/sched/act_pedit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index 1ef8fcfa9997..77c407eff3b0 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -515,11 +515,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
>  		spin_unlock_bh(&p->tcf_lock);
>  		return -ENOBUFS;
>  	}
> +	opt->nkeys = parms->tcfp_nkeys;
>  
>  	memcpy(opt->keys, parms->tcfp_keys,
>  	       flex_array_size(opt, keys, parms->tcfp_nkeys));
>  	opt->index = p->tcf_index;
> -	opt->nkeys = parms->tcfp_nkeys;
>  	opt->flags = parms->tcfp_flags;
>  	opt->action = p->tcf_action;
>  	opt->refcnt = refcount_read(&p->tcf_refcnt) - ref;
> -- 
> 2.34.1
> 

Coccinelle was not happy about the #define ...

struct tc_pedit_sel {
	tc_gen;
	unsigned char           nkeys;
	unsigned char           flags;
	struct tc_pedit_key     keys[0];
};

#define tc_pedit tc_pedit_sel

Also, it's not been converted to a proper flexible array...

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 01/14] ipv4: Annotate struct fib_info with __counted_by
  2023-09-22 17:28 ` [PATCH 01/14] ipv4: Annotate struct fib_info " Kees Cook
@ 2023-09-23  1:43   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:43 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: David S. Miller, David Ahern, Eric Dumazet, Paolo Abeni, netdev,
	Jamal Hadi Salim, 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,
	Shaokun Zhang, Cong Wang, Jiri Pirko, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 fib_info.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: David Ahern <dsahern@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   include/net/ip_fib.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
> index f0c13864180e..84b0a82c9df4 100644
> --- a/include/net/ip_fib.h
> +++ b/include/net/ip_fib.h
> @@ -156,7 +156,7 @@ struct fib_info {
>   	bool			nh_updated;
>   	struct nexthop		*nh;
>   	struct rcu_head		rcu;
> -	struct fib_nh		fib_nh[];
> +	struct fib_nh		fib_nh[] __counted_by(fib_nhs);
>   };
>   
>   

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 02/14] ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by
  2023-09-22 17:28 ` [PATCH 02/14] ipv4/igmp: Annotate struct ip_sf_socklist " Kees Cook
@ 2023-09-23  1:50   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:50 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: David S. Miller, Martin KaFai Lau, Gustavo A. R. Silva,
	Eric Dumazet, Alexei Starovoitov, Jamal Hadi Salim, David Ahern,
	Paolo Abeni, 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,
	Shaokun Zhang, Cong Wang, Jiri Pirko, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel, netdev,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 ip_sf_socklist.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Martin KaFai Lau <martin.lau@kernel.org>
> Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Alexei Starovoitov <ast@kernel.org>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   include/linux/igmp.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/igmp.h b/include/linux/igmp.h
> index ebf4349a53af..5171231f70a8 100644
> --- a/include/linux/igmp.h
> +++ b/include/linux/igmp.h
> @@ -39,7 +39,7 @@ struct ip_sf_socklist {
>   	unsigned int		sl_max;
>   	unsigned int		sl_count;
>   	struct rcu_head		rcu;
> -	__be32			sl_addr[];
> +	__be32			sl_addr[] __counted_by(sl_max);
>   };
>   
>   #define IP_SFBLOCK	10	/* allocate this many at once */

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 03/14] ipv6: Annotate struct ip6_sf_socklist with __counted_by
  2023-09-22 17:28 ` [PATCH 03/14] ipv6: Annotate struct ip6_sf_socklist " Kees Cook
@ 2023-09-23  1:51   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:51 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, netdev,
	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, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, linux-hyperv, linux-rdma, dev,
	linux-parisc, llvm, linux-hardening



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 ip6_sf_socklist.
> 
> [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: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   include/net/if_inet6.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/if_inet6.h b/include/net/if_inet6.h
> index c8490729b4ae..3e454c4d7ba6 100644
> --- a/include/net/if_inet6.h
> +++ b/include/net/if_inet6.h
> @@ -89,7 +89,7 @@ struct ip6_sf_socklist {
>   	unsigned int		sl_max;
>   	unsigned int		sl_count;
>   	struct rcu_head		rcu;
> -	struct in6_addr		sl_addr[];
> +	struct in6_addr		sl_addr[] __counted_by(sl_max);
>   };
>   
>   #define IP6_SFBLOCK	10	/* allocate this many at once */

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 04/14] net: hns: Annotate struct ppe_common_cb with __counted_by
  2023-09-22 17:28 ` [PATCH 04/14] net: hns: Annotate struct ppe_common_cb " Kees Cook
@ 2023-09-23  1:51   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:51 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Yisen Zhuang, Salil Mehta, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Claudiu Manoil, Vladimir Oltean, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 ppe_common_cb.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
> Cc: Salil Mehta <salil.mehta@huawei.com>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h
> index 0f0e16f9afc0..7e00231c1acf 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_ppe.h
> @@ -92,7 +92,7 @@ struct ppe_common_cb {
>   	u8 comm_index;   /*ppe_common index*/
>   
>   	u32 ppe_num;
> -	struct hns_ppe_cb ppe_cb[];
> +	struct hns_ppe_cb ppe_cb[] __counted_by(ppe_num);
>   
>   };
>   

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 05/14] net: enetc: Annotate struct enetc_int_vector with __counted_by
  2023-09-22 17:28 ` [PATCH 05/14] net: enetc: Annotate struct enetc_int_vector " Kees Cook
@ 2023-09-23  1:52   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:52 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Claudiu Manoil, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 enetc_int_vector.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Claudiu Manoil <claudiu.manoil@nxp.com>
> Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   drivers/net/ethernet/freescale/enetc/enetc.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h
> index 7439739cd81a..a9c2ff22431c 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc.h
> @@ -297,7 +297,7 @@ struct enetc_int_vector {
>   	char name[ENETC_INT_NAME_MAX];
>   
>   	struct enetc_bdr rx_ring;
> -	struct enetc_bdr tx_ring[];
> +	struct enetc_bdr tx_ring[] __counted_by(count_tx_rings);
>   } ____cacheline_aligned_in_smp;
>   
>   struct enetc_cls_rule {

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 06/14] net: hisilicon: Annotate struct rcb_common_cb with __counted_by
  2023-09-22 17:28 ` [PATCH 06/14] net: hisilicon: Annotate struct rcb_common_cb " Kees Cook
@ 2023-09-23  1:52   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:52 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Yisen Zhuang, Salil Mehta, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Claudiu Manoil, Vladimir Oltean, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 rcb_common_cb.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Yisen Zhuang <yisen.zhuang@huawei.com>
> Cc: Salil Mehta <salil.mehta@huawei.com>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
> index a9f805925699..c1e9b6997853 100644
> --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
> +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_rcb.h
> @@ -108,7 +108,7 @@ struct rcb_common_cb {
>   	u32 ring_num;
>   	u32 desc_num; /*  desc num per queue*/
>   
> -	struct ring_pair_cb ring_pair_cb[];
> +	struct ring_pair_cb ring_pair_cb[] __counted_by(ring_num);
>   };
>   
>   int hns_rcb_buf_size2type(u32 buf_size);

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 07/14] net: mana: Annotate struct mana_rxq with __counted_by
  2023-09-22 17:28 ` [PATCH 07/14] net: mana: Annotate struct mana_rxq " Kees Cook
@ 2023-09-23  1:55   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:55 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: K. Y. Srinivasan, Haiyang Zhang, Wei Liu, Dexuan Cui, Long Li,
	Ajay Sharma, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-hyperv, linux-rdma, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, Claudiu Manoil, Vladimir Oltean,
	Alex Elder, Pravin B Shelar, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, dev, linux-parisc, llvm,
	linux-hardening



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 mana_rxq.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Dexuan Cui <decui@microsoft.com>
> Cc: Long Li <longli@microsoft.com>
> Cc: Ajay Sharma <sharmaajay@microsoft.com>
> 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: linux-hyperv@vger.kernel.org
> Cc: linux-rdma@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>


Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   include/net/mana/mana.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h
> index 9f70b4332238..38441be68592 100644
> --- a/include/net/mana/mana.h
> +++ b/include/net/mana/mana.h
> @@ -338,7 +338,7 @@ struct mana_rxq {
>   	/* MUST BE THE LAST MEMBER:
>   	 * Each receive buffer has an associated mana_recv_buf_oob.
>   	 */
> -	struct mana_recv_buf_oob rx_oobs[];
> +	struct mana_recv_buf_oob rx_oobs[] __counted_by(num_rx_buf);
>   };
>   
>   struct mana_tx_qp {

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 08/14] net: ipa: Annotate struct ipa_power with __counted_by
  2023-09-22 17:28 ` [PATCH 08/14] net: ipa: Annotate struct ipa_power " Kees Cook
@ 2023-09-23  1:55   ` Gustavo A. R. Silva
  2023-09-23 12:09   ` Alex Elder
  1 sibling, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:55 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Alex Elder, David S. Miller, Eric Dumazet, Paolo Abeni, netdev,
	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,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 ipa_power.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Alex Elder <elder@kernel.org>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   drivers/net/ipa/ipa_power.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
> index 0eaa7a7f3343..e223886123ce 100644
> --- a/drivers/net/ipa/ipa_power.c
> +++ b/drivers/net/ipa/ipa_power.c
> @@ -67,7 +67,7 @@ struct ipa_power {
>   	spinlock_t spinlock;	/* used with STOPPED/STARTED power flags */
>   	DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT);
>   	u32 interconnect_count;
> -	struct icc_bulk_data interconnect[];
> +	struct icc_bulk_data interconnect[] __counted_by(interconnect_count);
>   };
>   
>   /* Initialize interconnects required for IPA operation */

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf with __counted_by
  2023-09-22 17:28 ` [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf " Kees Cook
@ 2023-09-23  1:56   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:56 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Long Li, Ajay Sharma, K. Y. Srinivasan, Haiyang Zhang, Wei Liu,
	Dexuan Cui, David S. Miller, Eric Dumazet, Paolo Abeni,
	linux-rdma, linux-hyperv, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, Claudiu Manoil, Vladimir Oltean,
	Alex Elder, Pravin B Shelar, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, dev, linux-parisc, llvm,
	linux-hardening



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 hwc_dma_buf.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Long Li <longli@microsoft.com>
> Cc: Ajay Sharma <sharmaajay@microsoft.com>
> Cc: "K. Y. Srinivasan" <kys@microsoft.com>
> Cc: Haiyang Zhang <haiyangz@microsoft.com>
> Cc: Wei Liu <wei.liu@kernel.org>
> Cc: Dexuan Cui <decui@microsoft.com>
> 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: linux-rdma@vger.kernel.org
> Cc: linux-hyperv@vger.kernel.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   include/net/mana/hw_channel.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/mana/hw_channel.h b/include/net/mana/hw_channel.h
> index 3d3b5c881bc1..158b125692c2 100644
> --- a/include/net/mana/hw_channel.h
> +++ b/include/net/mana/hw_channel.h
> @@ -121,7 +121,7 @@ struct hwc_dma_buf {
>   	u32 gpa_mkey;
>   
>   	u32 num_reqs;
> -	struct hwc_work_request reqs[];
> +	struct hwc_work_request reqs[] __counted_by(num_reqs);
>   };
>   
>   typedef void hwc_rx_event_handler_t(void *ctx, u32 gdma_rxq_id,

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance with __counted_by
  2023-09-22 17:28 ` [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance " Kees Cook
@ 2023-09-23  1:56   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:56 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Pravin B Shelar, David S. Miller, Eric Dumazet, Paolo Abeni,
	netdev, dev, 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, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, linux-parisc, llvm,
	linux-hardening



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 dp_meter_instance.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Pravin B Shelar <pshelar@ovn.org>
> 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
> Cc: dev@openvswitch.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   net/openvswitch/meter.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/openvswitch/meter.h b/net/openvswitch/meter.h
> index 0c33889a8515..013de694221f 100644
> --- a/net/openvswitch/meter.h
> +++ b/net/openvswitch/meter.h
> @@ -45,7 +45,7 @@ struct dp_meter {
>   struct dp_meter_instance {
>   	struct rcu_head rcu;
>   	u32 n_meters;
> -	struct dp_meter __rcu *dp_meters[];
> +	struct dp_meter __rcu *dp_meters[] __counted_by(n_meters);
>   };
>   
>   struct dp_meter_table {

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate with __counted_by
  2023-09-22 17:28 ` [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate " Kees Cook
@ 2023-09-23  1:56   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:56 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Claudiu Manoil, Vladimir Oltean, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, Jamal Hadi Salim, David Ahern,
	Martin KaFai Lau, Gustavo A. R. Silva, Alexei Starovoitov,
	Yisen Zhuang, Salil Mehta, K. Y. Srinivasan, Haiyang Zhang,
	Wei Liu, Dexuan Cui, Long Li, Ajay Sharma, Alex Elder,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 enetc_psfp_gate.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Claudiu Manoil <claudiu.manoil@nxp.com>
> Cc: Vladimir Oltean <vladimir.oltean@nxp.com>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   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

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 12/14] net: openvswitch: Annotate struct dp_meter with __counted_by
  2023-09-22 17:28 ` [PATCH 12/14] net: openvswitch: Annotate struct dp_meter " Kees Cook
@ 2023-09-23  1:57   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:57 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Pravin B Shelar, David S. Miller, Eric Dumazet, Paolo Abeni,
	netdev, dev, 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, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, linux-parisc, llvm,
	linux-hardening



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 dp_meter.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Pravin B Shelar <pshelar@ovn.org>
> 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
> Cc: dev@openvswitch.org
> Signed-off-by: Kees Cook <keescook@chromium.org>

Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>

Thanks
-- 
Gustavo

> ---
>   net/openvswitch/meter.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/openvswitch/meter.h b/net/openvswitch/meter.h
> index 013de694221f..ed11cd12b512 100644
> --- a/net/openvswitch/meter.h
> +++ b/net/openvswitch/meter.h
> @@ -39,7 +39,7 @@ struct dp_meter {
>   	u32 max_delta_t;
>   	u64 used;
>   	struct ovs_flow_stats stats;
> -	struct dp_meter_band bands[];
> +	struct dp_meter_band bands[] __counted_by(n_bands);
>   };
>   
>   struct dp_meter_instance {

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 13/14] net: tulip: Annotate struct mediatable with __counted_by
  2023-09-22 17:28 ` [PATCH 13/14] net: tulip: Annotate struct mediatable " Kees Cook
@ 2023-09-23  1:57   ` Gustavo A. R. Silva
  0 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  1:57 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Shaokun Zhang,
	netdev, linux-parisc, 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, linux-hyperv, linux-rdma, dev, llvm,
	linux-hardening



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
-- 
Gustavo

> ---
>   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);
>   };
>   
>   

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 14/14] net: sched: Annotate struct tc_pedit with __counted_by
  2023-09-22 17:28 ` [PATCH 14/14] net: sched: Annotate struct tc_pedit " Kees Cook
  2023-09-22 18:18   ` Kees Cook
  2023-09-22 18:23   ` Kees Cook
@ 2023-09-23  2:06   ` Gustavo A. R. Silva
  2 siblings, 0 replies; 37+ messages in thread
From: Gustavo A. R. Silva @ 2023-09-23  2:06 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Eric Dumazet, Paolo Abeni, netdev, 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, Shaokun Zhang, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening



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 tc_pedit.

I think the annotation for struct tc_pedit_sel is missing.

Thanks
--
Gustavo

> Additionally, since the element count member must be set before accessing
> the annotated flexible array member, move its initialization earlier.
> 
> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Jamal Hadi Salim <jhs@mojatatu.com>
> Cc: Cong Wang <xiyou.wangcong@gmail.com>
> Cc: Jiri Pirko <jiri@resnulli.us>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>   net/sched/act_pedit.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/sched/act_pedit.c b/net/sched/act_pedit.c
> index 1ef8fcfa9997..77c407eff3b0 100644
> --- a/net/sched/act_pedit.c
> +++ b/net/sched/act_pedit.c
> @@ -515,11 +515,11 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
>   		spin_unlock_bh(&p->tcf_lock);
>   		return -ENOBUFS;
>   	}
> +	opt->nkeys = parms->tcfp_nkeys;
>   
>   	memcpy(opt->keys, parms->tcfp_keys,
>   	       flex_array_size(opt, keys, parms->tcfp_nkeys));
>   	opt->index = p->tcf_index;
> -	opt->nkeys = parms->tcfp_nkeys;
>   	opt->flags = parms->tcfp_flags;
>   	opt->action = p->tcf_action;
>   	opt->refcnt = refcount_read(&p->tcf_refcnt) - ref;

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 08/14] net: ipa: Annotate struct ipa_power with __counted_by
  2023-09-22 17:28 ` [PATCH 08/14] net: ipa: Annotate struct ipa_power " Kees Cook
  2023-09-23  1:55   ` Gustavo A. R. Silva
@ 2023-09-23 12:09   ` Alex Elder
  2023-09-24  2:03     ` Kees Cook
  1 sibling, 1 reply; 37+ messages in thread
From: Alex Elder @ 2023-09-23 12:09 UTC (permalink / raw)
  To: Kees Cook, Jakub Kicinski
  Cc: Alex Elder, David S. Miller, Eric Dumazet, Paolo Abeni, netdev,
	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,
	Pravin B Shelar, Shaokun Zhang, Cong Wang, Jiri Pirko,
	Nathan Chancellor, Nick Desaulniers, Tom Rix, Simon Horman,
	linux-kernel, linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

On 9/22/23 12:28 PM, 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 ipa_power.

Looks good, thanks.

Reviewed-by: Alex Elder <elder@linaro.org>

Note that there is some interaction between struct ipa_power_data
and struct ipa_power (the former is used to initialize the latter).
Both of these contain flexible arrays counted by another field in
the structure.  It seems possible that the way these are initialized
might need slight modification to allow the compiler to do its
enforcement; if that's the case, please reach out to me.

					-Alex


> [1] https://github.com/kees/kernel-tools/blob/trunk/coccinelle/examples/counted_by.cocci
> 
> Cc: Alex Elder <elder@kernel.org>
> 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
> Signed-off-by: Kees Cook <keescook@chromium.org>
> ---
>   drivers/net/ipa/ipa_power.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ipa/ipa_power.c b/drivers/net/ipa/ipa_power.c
> index 0eaa7a7f3343..e223886123ce 100644
> --- a/drivers/net/ipa/ipa_power.c
> +++ b/drivers/net/ipa/ipa_power.c
> @@ -67,7 +67,7 @@ struct ipa_power {
>   	spinlock_t spinlock;	/* used with STOPPED/STARTED power flags */
>   	DECLARE_BITMAP(flags, IPA_POWER_FLAG_COUNT);
>   	u32 interconnect_count;
> -	struct icc_bulk_data interconnect[];
> +	struct icc_bulk_data interconnect[] __counted_by(interconnect_count);
>   };
>   
>   /* Initialize interconnects required for IPA operation */


^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 08/14] net: ipa: Annotate struct ipa_power with __counted_by
  2023-09-23 12:09   ` Alex Elder
@ 2023-09-24  2:03     ` Kees Cook
  0 siblings, 0 replies; 37+ messages in thread
From: Kees Cook @ 2023-09-24  2:03 UTC (permalink / raw)
  To: Alex Elder
  Cc: Jakub Kicinski, Alex Elder, David S. Miller, Eric Dumazet,
	Paolo Abeni, netdev, 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, Pravin B Shelar, Shaokun Zhang, Cong Wang,
	Jiri Pirko, Nathan Chancellor, Nick Desaulniers, Tom Rix,
	Simon Horman, linux-kernel, linux-hyperv, linux-rdma, dev,
	linux-parisc, llvm, linux-hardening

On Sat, Sep 23, 2023 at 07:09:19AM -0500, Alex Elder wrote:
> On 9/22/23 12:28 PM, 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 ipa_power.
> 
> Looks good, thanks.
> 
> Reviewed-by: Alex Elder <elder@linaro.org>
> 
> Note that there is some interaction between struct ipa_power_data
> and struct ipa_power (the former is used to initialize the latter).
> Both of these contain flexible arrays counted by another field in
> the structure.  It seems possible that the way these are initialized
> might need slight modification to allow the compiler to do its
> enforcement; if that's the case, please reach out to me.

I think it's all okay:

struct ipa_power_data {
        u32 core_clock_rate;
        u32 interconnect_count;         /* # entries in interconnect_data[] */
        const struct ipa_interconnect_data *interconnect_data;
};

"interconnect_data" here is a pointer, not a flexible array. (Yes,
__counted_by is expected to be expanded in the future for pointers,
but not yet.) Looking at initializers, I didn't see any problems with
how struct ipa_power is allocated.

Thanks for the heads-up; I'm sure I'll look at this again when we can
further expand __counted_by to pointers. :)

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/14] Batch 1: Annotate structs with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (13 preceding siblings ...)
  2023-09-22 17:28 ` [PATCH 14/14] net: sched: Annotate struct tc_pedit " Kees Cook
@ 2023-09-27 15:57 ` Kees Cook
  2023-10-02 18:26   ` Jakub Kicinski
  2023-10-02 18:40 ` patchwork-bot+netdevbpf
  15 siblings, 1 reply; 37+ messages in thread
From: Kees Cook @ 2023-09-27 15:57 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jamal Hadi Salim, David S. Miller, David Ahern, Eric Dumazet,
	Paolo Abeni, 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,
	Shaokun Zhang, Cong Wang, Jiri Pirko, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel, netdev,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

On Fri, Sep 22, 2023 at 10:28:42AM -0700, Kees Cook wrote:
> This is the batch 1 of patches touching netdev for preparing 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 to structs that would
> benefit from the annotation.
> 
> Since the element count member must be set before accessing the annotated
> flexible array member, some patches also move the member's initialization
> earlier. (These are noted in the individual patches.)

Hi, just checking on this batch of changes. Is it possible to take the
1-13 subset:

> Kees Cook (14):
>   ipv4: Annotate struct fib_info with __counted_by
>   ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by
>   ipv6: Annotate struct ip6_sf_socklist with __counted_by
>   net: hns: Annotate struct ppe_common_cb with __counted_by
>   net: enetc: Annotate struct enetc_int_vector with __counted_by
>   net: hisilicon: Annotate struct rcb_common_cb with __counted_by
>   net: mana: Annotate struct mana_rxq with __counted_by
>   net: ipa: Annotate struct ipa_power with __counted_by
>   net: mana: Annotate struct hwc_dma_buf with __counted_by
>   net: openvswitch: Annotate struct dp_meter_instance with __counted_by
>   net: enetc: Annotate struct enetc_psfp_gate with __counted_by
>   net: openvswitch: Annotate struct dp_meter with __counted_by
>   net: tulip: Annotate struct mediatable with __counted_by

I'll respin 14 and add it to the next batch:

>   net: sched: Annotate struct tc_pedit with __counted_by

After these 13, there are  32 more patches to various drivers and
protocols...

Thanks!

-Kees

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/14] Batch 1: Annotate structs with __counted_by
  2023-09-27 15:57 ` [PATCH 00/14] Batch 1: Annotate structs " Kees Cook
@ 2023-10-02 18:26   ` Jakub Kicinski
  2023-10-02 20:29     ` Kees Cook
  0 siblings, 1 reply; 37+ messages in thread
From: Jakub Kicinski @ 2023-10-02 18:26 UTC (permalink / raw)
  To: Kees Cook
  Cc: Jamal Hadi Salim, David S. Miller, David Ahern, Eric Dumazet,
	Paolo Abeni, 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,
	Shaokun Zhang, Cong Wang, Jiri Pirko, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel, netdev,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

On Wed, 27 Sep 2023 08:57:36 -0700 Kees Cook wrote:
> > Since the element count member must be set before accessing the annotated
> > flexible array member, some patches also move the member's initialization
> > earlier. (These are noted in the individual patches.)  
> 
> Hi, just checking on this batch of changes. Is it possible to take the
> 1-13 subset:

On it, sorry for the delay.

^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/14] Batch 1: Annotate structs with __counted_by
  2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
                   ` (14 preceding siblings ...)
  2023-09-27 15:57 ` [PATCH 00/14] Batch 1: Annotate structs " Kees Cook
@ 2023-10-02 18:40 ` patchwork-bot+netdevbpf
  15 siblings, 0 replies; 37+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-10-02 18:40 UTC (permalink / raw)
  To: Kees Cook
  Cc: kuba, jhs, davem, dsahern, edumazet, pabeni, martin.lau,
	gustavoars, ast, yisen.zhuang, salil.mehta, claudiu.manoil,
	vladimir.oltean, kys, haiyangz, wei.liu, decui, longli,
	sharmaajay, elder, pshelar, zhangshaokun, xiyou.wangcong, jiri,
	nathan, ndesaulniers, trix, horms, linux-kernel, netdev,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 22 Sep 2023 10:28:42 -0700 you wrote:
> Hi,
> 
> This is the batch 1 of patches touching netdev for preparing 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).
> 
> [...]

Here is the summary with links:
  - [01/14] ipv4: Annotate struct fib_info with __counted_by
    https://git.kernel.org/netdev/net-next/c/5b98fd5dc1e3
  - [02/14] ipv4/igmp: Annotate struct ip_sf_socklist with __counted_by
    https://git.kernel.org/netdev/net-next/c/210d4e9c732f
  - [03/14] ipv6: Annotate struct ip6_sf_socklist with __counted_by
    https://git.kernel.org/netdev/net-next/c/5d22b6528073
  - [04/14] net: hns: Annotate struct ppe_common_cb with __counted_by
    https://git.kernel.org/netdev/net-next/c/5b829c8460ae
  - [05/14] net: enetc: Annotate struct enetc_int_vector with __counted_by
    https://git.kernel.org/netdev/net-next/c/dd8e215ea9a8
  - [06/14] net: hisilicon: Annotate struct rcb_common_cb with __counted_by
    https://git.kernel.org/netdev/net-next/c/2290999d278e
  - [07/14] net: mana: Annotate struct mana_rxq with __counted_by
    https://git.kernel.org/netdev/net-next/c/a3d7a1209bbb
  - [08/14] net: ipa: Annotate struct ipa_power with __counted_by
    https://git.kernel.org/netdev/net-next/c/20551ee45d7d
  - [09/14] net: mana: Annotate struct hwc_dma_buf with __counted_by
    https://git.kernel.org/netdev/net-next/c/59656519763d
  - [10/14] net: openvswitch: Annotate struct dp_meter_instance with __counted_by
    https://git.kernel.org/netdev/net-next/c/e7b34822fa4d
  - [11/14] net: enetc: Annotate struct enetc_psfp_gate with __counted_by
    https://git.kernel.org/netdev/net-next/c/93bc6ab6b19d
  - [12/14] net: openvswitch: Annotate struct dp_meter with __counted_by
    https://git.kernel.org/netdev/net-next/c/16ae53d80c00
  - [13/14] net: tulip: Annotate struct mediatable with __counted_by
    https://git.kernel.org/netdev/net-next/c/0d01cfe5aaaf
  - [14/14] net: sched: Annotate struct tc_pedit with __counted_by
    (no matching commit)

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 37+ messages in thread

* Re: [PATCH 00/14] Batch 1: Annotate structs with __counted_by
  2023-10-02 18:26   ` Jakub Kicinski
@ 2023-10-02 20:29     ` Kees Cook
  0 siblings, 0 replies; 37+ messages in thread
From: Kees Cook @ 2023-10-02 20:29 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Jamal Hadi Salim, David S. Miller, David Ahern, Eric Dumazet,
	Paolo Abeni, 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,
	Shaokun Zhang, Cong Wang, Jiri Pirko, Nathan Chancellor,
	Nick Desaulniers, Tom Rix, Simon Horman, linux-kernel, netdev,
	linux-hyperv, linux-rdma, dev, linux-parisc, llvm,
	linux-hardening

On Mon, Oct 02, 2023 at 11:26:35AM -0700, Jakub Kicinski wrote:
> On Wed, 27 Sep 2023 08:57:36 -0700 Kees Cook wrote:
> > > Since the element count member must be set before accessing the annotated
> > > flexible array member, some patches also move the member's initialization
> > > earlier. (These are noted in the individual patches.)  
> > 
> > Hi, just checking on this batch of changes. Is it possible to take the
> > 1-13 subset:
> 
> On it, sorry for the delay.

No worries; thanks for grabbing them!

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 37+ messages in thread

end of thread, other threads:[~2023-10-02 20:29 UTC | newest]

Thread overview: 37+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-22 17:28 [PATCH 00/14] Batch 1: Annotate structs with __counted_by Kees Cook
2023-09-22 17:28 ` [PATCH 01/14] ipv4: Annotate struct fib_info " Kees Cook
2023-09-23  1:43   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 02/14] ipv4/igmp: Annotate struct ip_sf_socklist " Kees Cook
2023-09-23  1:50   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 03/14] ipv6: Annotate struct ip6_sf_socklist " Kees Cook
2023-09-23  1:51   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 04/14] net: hns: Annotate struct ppe_common_cb " Kees Cook
2023-09-23  1:51   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 05/14] net: enetc: Annotate struct enetc_int_vector " Kees Cook
2023-09-23  1:52   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 06/14] net: hisilicon: Annotate struct rcb_common_cb " Kees Cook
2023-09-23  1:52   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 07/14] net: mana: Annotate struct mana_rxq " Kees Cook
2023-09-23  1:55   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 08/14] net: ipa: Annotate struct ipa_power " Kees Cook
2023-09-23  1:55   ` Gustavo A. R. Silva
2023-09-23 12:09   ` Alex Elder
2023-09-24  2:03     ` Kees Cook
2023-09-22 17:28 ` [PATCH 09/14] net: mana: Annotate struct hwc_dma_buf " Kees Cook
2023-09-23  1:56   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 10/14] net: openvswitch: Annotate struct dp_meter_instance " Kees Cook
2023-09-23  1:56   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 11/14] net: enetc: Annotate struct enetc_psfp_gate " Kees Cook
2023-09-23  1:56   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 12/14] net: openvswitch: Annotate struct dp_meter " Kees Cook
2023-09-23  1:57   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 13/14] net: tulip: Annotate struct mediatable " Kees Cook
2023-09-23  1:57   ` Gustavo A. R. Silva
2023-09-22 17:28 ` [PATCH 14/14] net: sched: Annotate struct tc_pedit " Kees Cook
2023-09-22 18:18   ` Kees Cook
2023-09-22 18:23   ` Kees Cook
2023-09-23  2:06   ` Gustavo A. R. Silva
2023-09-27 15:57 ` [PATCH 00/14] Batch 1: Annotate structs " Kees Cook
2023-10-02 18:26   ` Jakub Kicinski
2023-10-02 20:29     ` Kees Cook
2023-10-02 18:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).