diff mbox series

[1/2] wifi: ath11k: annotate skb of struct ath11k_ce_ring with __counted_by

Message ID 20241021142745.585308-1-dmantipov@yandex.ru (mailing list archive)
State Rejected
Delegated to: Kalle Valo
Headers show
Series [1/2] wifi: ath11k: annotate skb of struct ath11k_ce_ring with __counted_by | expand

Commit Message

Dmitry Antipov Oct. 21, 2024, 2:27 p.m. UTC
According to 'ath11k_ce_alloc_ring()', annotate flexible array
member 'skb' of 'struct ath11k_ce_ring' with '__counted_by()'
to improve runtime bounds checking when CONFIG_UBSAN_BOUNDS is
enabled. Compile tested only.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 drivers/net/wireless/ath/ath11k/ce.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jeff Johnson Oct. 21, 2024, 4:30 p.m. UTC | #1
On 10/21/2024 7:27 AM, Dmitry Antipov wrote:
> According to 'ath11k_ce_alloc_ring()', annotate flexible array
> member 'skb' of 'struct ath11k_ce_ring' with '__counted_by()'
> to improve runtime bounds checking when CONFIG_UBSAN_BOUNDS is
> enabled. Compile tested only.
> 
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
>  drivers/net/wireless/ath/ath11k/ce.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath11k/ce.h b/drivers/net/wireless/ath/ath11k/ce.h
> index bcde2fcf02cf..9c54244970ce 100644
> --- a/drivers/net/wireless/ath/ath11k/ce.h
> +++ b/drivers/net/wireless/ath/ath11k/ce.h
> @@ -162,7 +162,7 @@ struct ath11k_ce_ring {
>  	u32 hal_ring_id;
>  
>  	/* keep last */
> -	struct sk_buff *skb[];
> +	struct sk_buff *skb[] __counted_by(nentries);
>  };
>  
>  struct ath11k_ce_pipe {

I won't be taking any of these without testing. I don't want to introduce
warnings due to the array being populated before setting the counter.

At a minimum you need to document where the counter is being set and verify
that is always done before accessing the flexible array.

(If it isn't broken, don't fix it)

/jeff
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath11k/ce.h b/drivers/net/wireless/ath/ath11k/ce.h
index bcde2fcf02cf..9c54244970ce 100644
--- a/drivers/net/wireless/ath/ath11k/ce.h
+++ b/drivers/net/wireless/ath/ath11k/ce.h
@@ -162,7 +162,7 @@  struct ath11k_ce_ring {
 	u32 hal_ring_id;
 
 	/* keep last */
-	struct sk_buff *skb[];
+	struct sk_buff *skb[] __counted_by(nentries);
 };
 
 struct ath11k_ce_pipe {