Message ID | 20241024112912.106104-1-dmantipov@yandex.ru (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,1/2] wifi: ath12k: annotate skb of struct ath12k_ce_ring with __counted_by | expand |
Please use get_maintainer.pl to make sure all the affected lists are notified. Your ath11k/ath12k patches aren't hitting the ath11k/ath12k lists so they aren't on my immediate radar. Also note I'm not taking any of these __counted_by() changes without actually either 1) testing with running code or 2) documenting all cases where the array is accessed and cross-referencing when the counting member is updated. I don't want to introduce any new warnings with your changes. "If the isn't broken, don't fix it." /jeff
diff --git a/drivers/net/wireless/ath/ath12k/ce.c b/drivers/net/wireless/ath/ath12k/ce.c index be0d669d31fc..23d984da2341 100644 --- a/drivers/net/wireless/ath/ath12k/ce.c +++ b/drivers/net/wireless/ath/ath12k/ce.c @@ -550,6 +550,9 @@ ath12k_ce_alloc_ring(struct ath12k_base *ab, int nentries, int desc_sz) if (!ce_ring) return ERR_PTR(-ENOMEM); + /* Note nentries should be set before populating skb[], + * otherwise __counted_by() might raise false positives. + */ ce_ring->nentries = nentries; ce_ring->nentries_mask = nentries - 1; diff --git a/drivers/net/wireless/ath/ath12k/ce.h b/drivers/net/wireless/ath/ath12k/ce.h index 857bc5f9e946..6967e3891030 100644 --- a/drivers/net/wireless/ath/ath12k/ce.h +++ b/drivers/net/wireless/ath/ath12k/ce.h @@ -135,7 +135,7 @@ struct ath12k_ce_ring { u32 hal_ring_id; /* keep last */ - struct sk_buff *skb[]; + struct sk_buff *skb[] __counted_by(nentries); }; struct ath12k_ce_pipe {
According to 'ath12k_ce_alloc_ring()', annotate flexible array member 'skb' of 'struct ath12k_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> --- v2: add related comment in ath12k_ce_alloc_ring() --- drivers/net/wireless/ath/ath12k/ce.c | 3 +++ drivers/net/wireless/ath/ath12k/ce.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-)