ice: fix validation issues in virtchnl parameters
Subsystems (3)
v3 cover ice: fix validation issues in virtchnl parameters
This patch series addresses validation issues in the virtchnl interface of the ice driver. These fixes correct improper value checking, ensuring that the driver can properly handle and reject invalid inputs from potentially malicious VFs. By fixing validation mechanisms, these patches strictly enforce existing constraints to prevent out-of-bounds scenarios, making the system more robust against incorrect or unexpected data.
---
v3 -> v2:
removed redundant check and fixed kfree being called on uninitialized var in 5. patch
v2 -> v1:
attached Mateusz's related patch
rephrase some commit messages to indicate that this are fixes and should target net
---
Jan Glaza (3):
virtchnl: make proto and filter action count unsigned
ice: stop truncating queue ids when checking
ice: validate queue quanta parameters to prevent OOB access
Lukasz Czapnik (1):
ice: fix input validation for virtchnl BW
Mateusz Polchlopek (1):
ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw()
drivers/net/ethernet/intel/ice/ice_virtchnl.c | 39 +++++++++++++++---- .../ethernet/intel/ice/ice_virtchnl_fdir.c | 24 +++++++----- include/linux/avf/virtchnl.h | 4 +- 3 files changed, 48 insertions(+), 19 deletions(-)
Signature · 1 line
2.47.0
PATCH v3 1/5 virtchnl: make proto and filter action count unsigned
From: Jan Glaza <[email protected]>
The count field in virtchnl_proto_hdrs and virtchnl_filter_action_set should never be negative while still being valid. Changing it from int to u32 ensures proper handling of values in virtchnl messages in driverrs and prevents unintended behavior.
In its current signed form, a negative count does not trigger an error in ice driver but instead results in it being treated as 0. This can lead to unexpected outcomes when processing messages. By using u32, any invalid values will correctly trigger -EINVAL, making error detection more robust.
--- include/linux/avf/virtchnl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/avf/virtchnl.h +2 -2
@@ -1343,7 +1343,7 @@ struct virtchnl_proto_hdrs {* 2 - from the second inner layer * .... **/ -int count;/* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */ +u32 count;/* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */ union {struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS ];
@@ -1395,7 +1395,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);struct virtchnl_filter_action_set {/* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ -int count; +u32 count;struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS ]; };
Signature · 1 line
2.47.0
Re: [Intel-wired-lan] [iwl-net v3 1/5] virtchnl: make proto and filter action count unsigned
Dear Jan, dear Martina,
Thank you for the patch.
Am 04.03.25 um 12:08 schrieb Martyna Szapar-Mudlaw:
Quoted 26 lines
From: Jan Glaza <[email protected]>
The count field in
virtchnl_proto_hdrsandvirtchnl_filter_action_setshould never be negative while still being valid. Changing it from int to u32 ensures proper handling of values in virtchnl messages in driverrs and prevents unintended behavior.
In its current signed form, a negative count does not trigger an error in ice driver but instead results in it being treated as 0. This can lead to unexpected outcomes when processing messages. By using u32, any invalid values will correctly trigger-EINVAL, making error detection more robust.Fixes 1f7ea1cd6a374 ("ice: Enable FDIR Configure for AVF")Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <[email protected]>--- include/linux/avf/virtchnl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)include/linux/avf/virtchnl.h +0
-0
include/linux/avf/virtchnl.h struct virtchnl_proto_hdrs { · line 1346
Quoted 5 lines
include/linux/avf/virtchnl.h +1
-1@@ -1343,7 +1343,7 @@ struct virtchnl_proto_hdrs {* 2 - from the second inner layer * .... **/ -int count;/* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */ +u32 count;/* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */
Why limit the length, and not use unsigned int?
include/linux/avf/virtchnl.h VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); · line 1400
Quoted 11 lines
include/linux/avf/virtchnl.h +1
-1union {struct virtchnl_proto_hdr proto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS ];@@ -1395,7 +1395,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action);struct virtchnl_filter_action_set {/* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ -int count; +u32 count;struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS ]; };
Kind regards,
Paul
Re: [Intel-wired-lan] [iwl-net v3 1/5] virtchnl: make proto and filter action count unsigned
Quoted 27 lines · Paul Menzel
Dear Jan, dear Martina,
Thank you for the patch.
Am 04.03.25 um 12:08 schrieb Martyna Szapar-Mudlaw:
Quoted 21 lines
From: Jan Glaza <[email protected]>
The count field in
virtchnl_proto_hdrsandvirtchnl_filter_action_setshould never be negative while still being valid. Changing it from int to u32 ensures proper handling of values in virtchnl messages in driverrs and prevents unintended behavior.
In its current signed form, a negative count does not trigger an error in ice driver but instead results in it being treated as 0. This can lead to unexpected outcomes when processing messages. By using u32, any invalid values will correctly trigger-EINVAL, making error detection more robust.Fixes 1f7ea1cd6a374 ("ice: Enable FDIR Configure for AVF")Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <martyna.szapar- [email protected]>---
include/linux/avf/virtchnl.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 13 lines
include/linux/avf/virtchnl.h struct virtchnl_proto_hdrs { · line 1346
Quoted 10 lines
include/linux/avf/virtchnl.h +1
-1@@ -1343,7 +1343,7 @@ struct virtchnl_proto_hdrs {* 2 - from the second inner layer * .... **/ - int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */ + u32 count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */Why limit the length, and not use unsigned int?
u32 range is completely sufficient for number of proto hdrs (as said: "the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS") and I believe it is recommended to use fixed sized variables where possible
Quoted 17 lines
include/linux/avf/virtchnl.h VIRTCHNL_CHECK_STRUCT_LEN(36, · line 1400
Quoted 11 lines
include/linux/avf/virtchnl.h +0
-0union {struct
virtchnl_proto_hdrproto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];include/linux/avf/virtchnl.h +1
-1@@ -1395,7 +1395,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); struct virtchnl_filter_action_set { /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ - int count; + u32 count; struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]; };Kind regards,
Paul
Re: [Intel-wired-lan] [iwl-net v3 1/5] virtchnl: make proto and filter action count unsigned
Dear Martyna,
Thank you for your quick reply.
Am 04.03.25 um 12:45 schrieb Szapar-Mudlaw, Martyna:
Quoted 37 lines · Paul Menzel
Quoted 23 lines
Am 04.03.25 um 12:08 schrieb Martyna Szapar-Mudlaw:
Quoted 21 lines
From: Jan Glaza <[email protected]>
The count field in
virtchnl_proto_hdrsandvirtchnl_filter_action_setshould never be negative while still being valid. Changing it from int to u32 ensures proper handling of values in virtchnl messages in driverrs and prevents unintended behavior.
In its current signed form, a negative count does not trigger an error in ice driver but instead results in it being treated as 0. This can lead to unexpected outcomes when processing messages. By using u32, any invalid values will correctly trigger-EINVAL, making error detection more robust.Fixes 1f7ea1cd6a374 ("ice: Enable FDIR Configure for AVF")Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <[email protected]>---
include/linux/avf/virtchnl.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)Quoted 12 lines
include/linux/avf/virtchnl.h struct virtchnl_proto_hdrs { · line 1346
Quoted 10 lines
include/linux/avf/virtchnl.h +1
-1@@ -1343,7 +1343,7 @@ struct virtchnl_proto_hdrs {* 2 - from the second inner layer * .... **/ - int count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */ + u32 count; /* the proto layers must < VIRTCHNL_MAX_NUM_PROTO_HDRS */Why limit the length, and not use unsigned int?
Quoted 1 line
u32 range is completely sufficient for number of proto hdrs (as said: "the proto layers must <
VIRTCHNL_MAX_NUM_PROTO_HDRS") and I believe it is recommended to use fixed sized variables where possible
Do you have a pointer to the recommendation? I heard the opposite, that fixed length is only useful for register writes. Otherwise, you should use the “generic” types [1].
Quoted 10 lines
Quoted 10 lines
include/linux/avf/virtchnl.h VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); · line 1399
Quoted 10 lines
include/linux/avf/virtchnl.h +0
-0union {struct
virtchnl_proto_hdrproto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];include/linux/avf/virtchnl.h +1
-1@@ -1395,7 +1395,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); struct virtchnl_filter_action_set { /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ - int count; + u32 count; struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]; };
Kind regards,
Paul
Re: [Intel-wired-lan] [iwl-net v3 1/5] virtchnl: make proto and filter action count unsigned
Quoted 46 lines · Paul Menzel
Dear Martyna,
Thank you for your quick reply.
Am 04.03.25 um 12:45 schrieb Szapar-Mudlaw, Martyna:
Quoted 39 lines · Paul Menzel
Quoted 37 lines
Am 04.03.25 um 12:08 schrieb Martyna Szapar-Mudlaw:
Quoted 30 lines
From: Jan Glaza <[email protected]>
The count field in
virtchnl_proto_hdrsandvirtchnl_filter_action_setshould never be negative while still being valid. Changing it from int to u32 ensures proper handling of values in virtchnl messages in driverrs and prevents unintended behavior.
In its current signed form, a negative count does not trigger an error in ice driver but instead results in it being treated as 0. This can lead to unexpected outcomes when processing messages. By using u32, any invalid values will correctly trigger-EINVAL, making error detection more robust.Fixes 1f7ea1cd6a374 ("ice: Enable FDIR Configure for AVF")Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <martyna.szapar- [email protected]>---
include/linux/avf/virtchnl.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)include/linux/avf/virtchnl.h +0
-1@@ -1343,7 +1343,7 @@ struct virtchnl_proto_hdrs {* 2 - from the second inner layer * .... **/ - int count; /* the proto layers must <Quoted 3 lines
VIRTCHNL_MAX_NUM_PROTO_HDRS*/
+ u32 count; /* the proto layers must <VIRTCHNL_MAX_NUM_PROTO_HDRS*/Why limit the length, and not use unsigned int?
Quoted 3 lines
Quoted 1 line
u32 range is completely sufficient for number of proto hdrs (as said: "the proto layers must <
VIRTCHNL_MAX_NUM_PROTO_HDRS") and I believe it is recommended to use fixed sized variables where possibleDo you have a pointer to the recommendation? I heard the opposite, that fixed length is only useful for register writes. Otherwise, you should use the “generic” types [1].
Thanks for sharing the source and your perspective, you are right, as a general rule, using generic types is preferred - I actually learned something new from this. That said, I still believe there are exceptions, and in this case, using u32 is the right choice. When dealing with protocols or data formats using a fixed-width type makes sense. Additionally, throughout this file, we consistently use u32/u16 for similar cases, so also here we're keeping it aligned with the existing codebase. Thank you for your review and appreciate the discussion on best practices.
Regards,
Martyna
Quoted 20 lines
Quoted 12 lines
Quoted 12 lines
include/linux/avf/virtchnl.h VIRTCHNL_CHECK_STRUCT_LEN(36, · line 1400
Quoted 12 lines
union {
structvirtchnl_proto_hdrproto_hdr[VIRTCHNL_MAX_NUM_PROTO_HDRS];include/linux/avf/virtchnl.h +1
-1@@ -1395,7 +1395,7 @@ VIRTCHNL_CHECK_STRUCT_LEN(36, virtchnl_filter_action); struct virtchnl_filter_action_set { /* action number must be less then VIRTCHNL_MAX_NUM_ACTIONS */ - int count; + u32 count; struct virtchnl_filter_action actions[VIRTCHNL_MAX_NUM_ACTIONS]; };Kind regards,
Paul
Romanowski, Rafal
Tested-byRE: [Intel-wired-lan] [iwl-net v3 1/5] virtchnl: make proto and filter action count unsigned
Quoted 46 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Szapar-Mudlaw, Martyna
Sent: Tuesday, March 4, 2025 2:12 PM
To: Paul Menzel <[email protected]>; Glaza, Jan <[email protected]>
Cc: [email protected]; [email protected]; Jagielski, Jedrzej <[email protected]>; Simon Horman <[email protected]>; Lobakin, Aleksander <[email protected]>
Subject: Re: [Intel-wired-lan] [iwl-net v3 1/5] virtchnl: make proto and filter action count unsignedQuoted 32 lines · Paul Menzel
Dear Martyna,
Thank you for your quick reply.
Am 04.03.25 um 12:45 schrieb Szapar-Mudlaw, Martyna:
Quoted 25 lines · Paul Menzel
Quoted 24 lines
Am 04.03.25 um 12:08 schrieb Martyna Szapar-Mudlaw:
Quoted 22 lines
From: Jan Glaza <[email protected]>
The count field in
virtchnl_proto_hdrsandvirtchnl_filter_action_setshould never be negative while still being valid. Changing it from int to u32 ensures proper handling of values in virtchnl messages in driverrs and prevents unintended behavior. In its current signed form, a negative count does not trigger an error in ice driver but instead results in it being treated as 0. This can lead to unexpected outcomes when processing messages. By using u32, any invalid values will correctly trigger-EINVAL, making error detection more robust.Fixes 1f7ea1cd6a374 ("ice: Enable FDIR Configure for AVF")Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <martyna.szapar-[email protected]>
---
include/linux/avf/virtchnl.h| 4 ++--1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
include/linux/avf/virtchnl.h struct virtchnl_proto_hdrs {
Quoted 5 lines
include/linux/avf/ renamed from include/linux/avf/virtchnl.h +0
-0
virtchnl.hindex4811b9a14604..cf0afa60e4a7100644include/linux/avf/virtchnl.h +0
-0@@ -1343,7 +1343,7 @@ struct virtchnl_proto_hdrs {
PATCH v3 2/5 ice: stop truncating queue ids when checking
In reply to Martyna Szapar-MudlawFrom: Jan Glaza <[email protected]>
Queue IDs can be up to 4096, fix invalid check to stop truncating IDs to 8 bits.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +1 -1
@@ -565,7 +565,7 @@ bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)* * check for the valid queue ID */ -static bool ice_vc_isvalid_q_id (struct ice_vsi *vsi,u8 qid) +static bool ice_vc_isvalid_q_id (struct ice_vsi *vsi,u16 qid) {/* allocated Tx and Rx queues should be always equal for VF VSI */ return qid < vsi->alloc_txq;
Signature · 1 line
2.47.0
RE: [Intel-wired-lan] [iwl-net v3 2/5] ice: stop truncating queue ids when checking
drivers/net/ethernet/intel/ice/ice_virtchnl.c bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)
Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Martyna Szapar-Mudlaw
Sent: Tuesday, March 4, 2025 12:09 PM
To: [email protected]
Cc: [email protected]; Glaza, Jan <[email protected]>; Loktionov, Aleksandr <[email protected]>; Jagielski, Jedrzej <[email protected]>; Simon Horman <[email protected]>; Martyna Szapar-Mudlaw <[email protected]>
Subject: [Intel-wired-lan] [iwl-net v3 2/5] ice: stop truncating queue ids when checkingFrom: Jan Glaza <[email protected]>
Queue IDs can be up to 4096, fix invalid check to stop truncating IDs to 8 bits.
Fixes bf93bf791cec8 ("ice: introduce ice_virtchnl.c and ice_virtchnl.h")Reviewed-by Aleksandr Loktionov <[email protected]>Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <martyna.szapar---- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_virtchnl.c +0
-0@@ -565,7 +565,7 @@ bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id)
PATCH v3 3/5 ice: validate queue quanta parameters to prevent OOB access
In reply to Martyna Szapar-MudlawFrom: Jan Glaza <[email protected]>
Add queue wraparound prevention in quanta configuration. Ensure end_qid does not overflow by validating start_qid and num_queues.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +9 -4
@@ -1903,13 +1903,21 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)*/ static int ice_vc_cfg_q_quanta (struct ice_vf *vf,u8 *msg) { +u16 quanta_prof_id, quanta_size, start_qid, num_queues, end_qid, i;enum virtchnl_status_code v_ret =VIRTCHNL_STATUS_SUCCESS ; -u16 quanta_prof_id, quanta_size, start_qid, end_qid, i;struct virtchnl_quanta_cfg *qquanta = (struct virtchnl_quanta_cfg *)msg;struct ice_vsi *vsi;int ret; + start_qid = qquanta->queue_select.start_queue_id; + num_queues = qquanta->queue_select.num_queues; + +if (check_add_overflow (start_qid, num_queues, &end_qid)) { + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; + goto err; + } +if (!test_bit (ICE_VF_STATE_ACTIVE , vf->vf_states)) { v_ret =VIRTCHNL_STATUS_ERR_PARAM ; goto err;
@@ -1921,8 +1929,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg) goto err; } - end_qid = qquanta->queue_select.start_queue_id + - qquanta->queue_select.num_queues;if (end_qid >ICE_MAX_RSS_QS_PER_VF || end_qid >min_t (u16, vsi->alloc_txq, vsi->alloc_rxq)) { dev_err(ice_pf_to_dev(vf->pf), "VF-%d trying to configure more than allocated number of queues: %d\n",
@@ -1951,7 +1957,6 @@ static int ice_vc_cfg_q_quanta(struct ice_vf *vf, u8 *msg) goto err; } - start_qid = qquanta->queue_select.start_queue_id;for (i = start_qid; i < end_qid; i++) vsi->tx_rings[i]->quanta_prof_id = quanta_prof_id;
Signature · 1 line
2.47.0
RE: [Intel-wired-lan] [iwl-net v3 3/5] ice: validate queue quanta parameters to prevent OOB access
drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8
Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Martyna Szapar-Mudlaw
Sent: Tuesday, March 4, 2025 12:09 PM
To: [email protected]
Cc: [email protected]; Glaza, Jan <[email protected]>; Jagielski, Jedrzej <[email protected]>; Simon Horman <[email protected]>; Martyna Szapar-Mudlaw <[email protected]>
Subject: [Intel-wired-lan] [iwl-net v3 3/5] ice: validate queue quanta parameters to prevent OOB accessFrom: Jan Glaza <[email protected]>
Add queue wraparound prevention in quanta configuration. Ensure
end_qiddoes not overflow by validatingstart_qidandnum_queues.Fixes 015307754a19 ("ice: Support VF queue rate limit and quanta sizeconfiguration")
Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Jan Glaza <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <martyna.szapar---- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)drivers/net/ethernet/intel/ice/ice_virtchnl.c +0
-0@@ -1903,13 +1903,21 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8
PATCH v3 4/5 ice: fix input validation for virtchnl BW
In reply to Martyna Szapar-MudlawFrom: Lukasz Czapnik <[email protected]>
Add missing validation of tc and queue id values sent by a VF in ice_vc_cfg_q_bw().
Additionally fixed logged value in the warning message, where max_tx_rate was incorrectly referenced instead of min_tx_rate. Also correct error handling in this function by properly exiting when invalid configuration is detected.
--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl.c +21 -3
@@ -1865,15 +1865,33 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8 *msg)for (i =0 ; i < qbw->num_queues; i++) {if (qbw->cfg[i].shaper.peak !=0 && vf->max_tx_rate !=0 && - qbw->cfg[i].shaper.peak > vf->max_tx_rate) + qbw->cfg[i].shaper.peak > vf->max_tx_rate) {dev_warn (ice_pf_to_dev (vf->pf),"The maximum queue %d rate limit configuration may not take effect because the maximum TX rate for VF-%d is %d\n" , qbw->cfg[i].queue_id, vf->vf_id, vf->max_tx_rate); + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; + goto err; + }if (qbw->cfg[i].shaper.committed !=0 && vf->min_tx_rate !=0 && - qbw->cfg[i].shaper.committed < vf->min_tx_rate) + qbw->cfg[i].shaper.committed < vf->min_tx_rate) {dev_warn (ice_pf_to_dev (vf->pf),"The minimum queue %d rate limit configuration may not take effect because the minimum TX rate for VF-%d is %d\n" , qbw->cfg[i].queue_id, vf->vf_id, - vf->max_tx_rate); + vf->min_tx_rate); + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; + goto err; + } +if (qbw->cfg[i].queue_id > vf->num_vf_qs) { +dev_warn (ice_pf_to_dev (vf->pf),"VF-%d trying to configure invalid queue_id\n" , + vf->vf_id); + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; + goto err; + } +if (qbw->cfg[i].tc >=ICE_MAX_TRAFFIC_CLASS ) { +dev_warn (ice_pf_to_dev (vf->pf),"VF-%d trying to configure a traffic class higher than allowed\n" , + vf->vf_id); + v_ret =VIRTCHNL_STATUS_ERR_PARAM ; + goto err; + } }for (i =0 ; i < qbw->num_queues; i++) {
Signature · 1 line
2.47.0
RE: [Intel-wired-lan] [iwl-net v3 4/5] ice: fix input validation for virtchnl BW
drivers/net/ethernet/intel/ice/ice_virtchnl.c static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8
Quoted 39 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Martyna Szapar-Mudlaw
Sent: Tuesday, March 4, 2025 12:09 PM
To: [email protected]
Cc: [email protected]; Czapnik, Lukasz <[email protected]>; Jagielski, Jedrzej <[email protected]>; Simon Horman <[email protected]>; Martyna Szapar-Mudlaw <martyna.szapar- [email protected]>
Subject: [Intel-wired-lan] [iwl-net v3 4/5] ice: fix input validation for virtchnl BWFrom: Lukasz Czapnik <[email protected]>
Add missing validation of tc and queue id values sent by a VF in
ice_vc_cfg_q_bw().
Additionally fixed logged value in the warning message, wheremax_tx_ratewas incorrectly referenced instead ofmin_tx_rate.
Also correct error handling in this function by properly exiting when invalid configuration is detected.Fixes 015307754a19 ("ice: Support VF queue rate limit and quanta sizeconfiguration")
Reviewed-by Jedrzej Jagielski <[email protected]>Reviewed-by Simon Horman <[email protected]>Signed-off-by Lukasz Czapnik <[email protected]>Co-developed-by Martyna Szapar-Mudlaw <martyna.szapar-[email protected]>
Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar- [email protected]>--- drivers/net/ethernet/intel/ice/ice_virtchnl.c | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-)drivers/net/ethernet/intel/ice/ice_virtchnl.c +0
-0@@ -1865,15 +1865,33 @@ static int ice_vc_cfg_q_bw(struct ice_vf *vf, u8
PATCH v3 5/5 ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw()
In reply to Martyna Szapar-MudlawFrom: Mateusz Polchlopek <[email protected]>
Fix using the untrusted value of proto->raw.pkt_len in function ice_vc_fdir_parse_raw() by verifying if it does not exceed the VIRTCHNL_MAX_SIZE_RAW_PACKET value.
--- .../ethernet/intel/ice/ice_virtchnl_fdir.c | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +15 -9
@@ -832,21 +832,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,struct virtchnl_proto_hdrs *proto, struct virtchnl_fdir_fltr_conf *conf) { - u8 *pkt_buf, *msk_buf __free(kfree); + u8 *pkt_buf, *msk_buf __free(kfree) = NULL;struct ice_parser_result rslt;struct ice_pf *pf = vf->pf; +u16 pkt_len, udp_port =0 ;struct ice_parser *psr;int status = -ENOMEM ;struct ice_hw *hw; -u16 udp_port =0 ; - pkt_buf =kzalloc (proto->raw.pkt_len,GFP_KERNEL ); - msk_buf =kzalloc (proto->raw.pkt_len,GFP_KERNEL ); + pkt_len = proto->raw.pkt_len; + +if (!pkt_len || pkt_len >VIRTCHNL_MAX_SIZE_RAW_PACKET ) +return -EINVAL ; + + pkt_buf =kzalloc (pkt_len,GFP_KERNEL ); + msk_buf =kzalloc (pkt_len,GFP_KERNEL ); +if (!pkt_buf || !msk_buf) goto err_mem_alloc; -memcpy (pkt_buf, proto->raw.spec, proto->raw.pkt_len); -memcpy (msk_buf, proto->raw.mask, proto->raw.pkt_len); +memcpy (pkt_buf, proto->raw.spec, pkt_len); +memcpy (msk_buf, proto->raw.mask, pkt_len); hw = &pf->hw;
@@ -862,7 +868,7 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,if (ice_get_open_tunnel_port (hw, &udp_port,TNL_VXLAN ))ice_parser_vxlan_tunnel_set (psr, udp_port, true); - status =ice_parser_run (psr, pkt_buf, proto->raw.pkt_len, &rslt); + status =ice_parser_run (psr, pkt_buf, pkt_len, &rslt);if (status) goto err_parser_destroy;
@@ -876,7 +882,7 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf, } status =ice_parser_profile_init (&rslt, pkt_buf, msk_buf, - proto->raw.pkt_len,ICE_BLK_FD , + pkt_len,ICE_BLK_FD , conf->prof);if (status) goto err_parser_profile_init;
@@ -885,7 +891,7 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,ice_parser_profile_dump (hw, conf->prof);/* Store raw flow info into @conf */ - conf->pkt_len = proto->raw.pkt_len; + conf->pkt_len = pkt_len; conf->pkt_buf = pkt_buf; conf->parser_ena = true;
Signature · 1 line
2.47.0
RE: [Intel-wired-lan] [iwl-net v3 5/5] ice: fix using untrusted value of pkt_len in ice_vc_fdir_parse_raw()
drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c ice_vc_fdir_parse_raw(struct ice_vf *vf,
Quoted 33 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Martyna Szapar-Mudlaw
Sent: Tuesday, March 4, 2025 12:09 PM
To: [email protected]
Cc: [email protected]; Polchlopek, Mateusz <[email protected]>; Kitszel, Przemyslaw <[email protected]>; Martyna Szapar-Mudlaw <martyna.szapar- [email protected]>
Subject: [Intel-wired-lan] [iwl-net v3 5/5] ice: fix using untrusted value ofpkt_leninice_vc_fdir_parse_raw()From: Mateusz Polchlopek <[email protected]>
Fix using the untrusted value of
proto->raw.pkt_lenin functionice_vc_fdir_parse_raw()by verifying if it does not exceed theVIRTCHNL_MAX_SIZE_RAW_PACKETvalue.Fixes 99f419df8a5c ("ice: enable FDIR filters from raw binary patterns for VFs")Reviewed-by Przemek Kitszel <[email protected]>Signed-off-by Mateusz Polchlopek <[email protected]>Signed-off-by Martyna Szapar-Mudlaw <martyna.szapar---- .../ethernet/intel/ice/ice_virtchnl_fdir.c | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-)drivers/net/ethernet/intel/ice/ice_virtchnl_fdir.c +0
-0@@ -832,21 +832,27 @@ ice_vc_fdir_parse_raw(struct ice_vf *vf,