Skip to contentSkip to conversation

ice: Fix off by one in ice_tc_forward_to_queue()

PATCH In review Dan Carpenter 3 participants 3 messages Oct 28, 2022 – Dec 1, 2022

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ice: Fix off by one in ice_tc_forward_to_queue()

The > comparison should be >= to prevent reading one element beyond the end of the array.

The "vsi->num_rxq" is not strictly speaking the number of elements in the vsi->rxq_map[] array. The array has "vsi->alloc_rxq" elements and "vsi->num_rxq" is less than or equal to the number of elements in the array. The array is allocated in ice_vsi_alloc_arrays(). It's still an off by one but it might not access outside the end of the array.

Fixes 143b86f346c7 ("ice: Enable RX queue selection using skbedit action")

---
Applies to net-next.

 drivers/net/ethernet/intel/ice/ice_tc_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_tc_lib.c +1 -1
index faba0f857cd9..95f392ab9670 100644
@@ -1681,7 +1681,7 @@ ice_tc_forward_to_queue(struct ice_vsi *vsi, struct ice_tc_flower_fltr *fltr,
 	struct ice_vsi *ch_vsi = NULL;
 	u16 queue = act->rx_queue;
 
-	if (queue > vsi->num_rxq) {
+	if (queue >= vsi->num_rxq) {
 		NL_SET_ERR_MSG_MOD(fltr->extack,
 				   "Unable to add filter because specified queue is invalid");
 		return -EINVAL;
Signature · 6 lines
2.35.1

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
Acked-by on v1 1/1
#1 lore raw
Quoted 16 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Friday, October 28, 2022 8:02 AM
To: Brandeburg, Jesse <[email protected]>; Nambiar, Amritha <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Samudrala, Sridhar <[email protected]>; Gomes, Vinicius <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next] ice: Fix off by one in ice_tc_forward_to_queue()

The > comparison should be >= to prevent reading one element beyond the end of the array.

Quoted 8 lines

The "vsi->num_rxq" is not strictly speaking the number of elements in the vsi->rxq_map[] array. The array has "vsi->alloc_rxq" elements and "vsi->num_rxq" is less than or equal to the number of elements in the array. The array is allocated in ice_vsi_alloc_arrays(). It's still an off by one but it might not access outside the end of the array.

Fixes 143b86f346c7 ("ice: Enable RX queue selection using skbedit action")
Quoted 24 lines

---
Applies to net-next.

 drivers/net/ethernet/intel/ice/ice_tc_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_tc_lib.c +1 -1
index faba0f857cd9..95f392ab9670 100644
@@ -1681,7 +1681,7 @@ ice_tc_forward_to_queue(struct ice_vsi *vsi, struct
 ice_tc_flower_fltr *fltr,
 	struct ice_vsi *ch_vsi = NULL;
 	u16 queue = act->rx_queue;
 
-	if (queue > vsi->num_rxq) {
+	if (queue >= vsi->num_rxq) {
 		NL_SET_ERR_MSG_MOD(fltr->extack,
 				   "Unable to add filter because specified

queue is invalid");
return -EINVAL;
--
2.35.1

#2 lore raw
Quoted 38 lines

-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Nambiar, Amritha
Sent: Saturday, October 29, 2022 2:58 AM
To: Dan Carpenter <[email protected]>; Brandeburg, Jesse <[email protected]>
Cc: [email protected]; Eric Dumazet <[email protected]>; [email protected]; intel-wired- [email protected]; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; David S. Miller <[email protected]>
Subject: Re: [Intel-wired-lan] [PATCH net-next] ice: Fix off by one in ice_tc_forward_to_queue()

Quoted 23 lines

-----Original Message-----
From: Dan Carpenter <[email protected]>
Sent: Friday, October 28, 2022 8:02 AM
To: Brandeburg, Jesse <[email protected]>; Nambiar, Amritha <[email protected]>
Cc: Nguyen, Anthony L <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; Samudrala, Sridhar <[email protected]>; Gomes, Vinicius <[email protected]>; [email protected]; [email protected]; [email protected]
Subject: [PATCH net-next] ice: Fix off by one in ice_tc_forward_to_queue()

The > comparison should be >= to prevent reading one element beyond the end of the array.

The "vsi->num_rxq" is not strictly speaking the number of elements in the vsi->rxq_map[] array. The array has "vsi->alloc_rxq" elements and "vsi->num_rxq" is less than or equal to the number of elements in the array. The array is allocated in ice_vsi_alloc_arrays(). It's still an off by one but it might not access outside the end of the array.

Quoted 12 lines
Quoted 3 lines
Fixes 143b86f346c7 ("ice: Enable RX queue selection using skbedit

action")

Quoted 6 lines

---
Applies to net-next.

 drivers/net/ethernet/intel/ice/ice_tc_lib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

_______________________________________________
Intel-wired-lan mailing list
[email protected]
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan