[v2] net/ice: fix data length check

Message ID 20230523103509.2918185-1-qi.z.zhang@intel.com (mailing list archive)
State Rejected, archived
Delegated to: Qi Zhang
Headers
Series [v2] net/ice: fix data length check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Qi Zhang May 23, 2023, 10:35 a.m. UTC
  In TSO, It is possible mbuf->data_len exceed mtu.
Fixed the incorrect data length check in ice_prep_pkts.

Fixes: ccf33dccf7aa ("net/ice: check illegal packet sizes")
Cc: stable@dpdk.org

Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
---
v2:
- fix build warning

 drivers/net/ice/ice_rxtx.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
  

Comments

Qi Zhang June 9, 2023, 1:50 a.m. UTC | #1
> -----Original Message-----
> From: Zhang, Qi Z <qi.z.zhang@intel.com>
> Sent: Tuesday, May 23, 2023 6:35 PM
> To: Yang, Qiming <qiming.yang@intel.com>
> Cc: dev@dpdk.org; Zhang, Qi Z <qi.z.zhang@intel.com>; stable@dpdk.org
> Subject: [PATCH v2] net/ice: fix data length check
> 
> In TSO, It is possible mbuf->data_len exceed mtu.
> Fixed the incorrect data length check in ice_prep_pkts.
> 
> Fixes: ccf33dccf7aa ("net/ice: check illegal packet sizes")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Qi Zhang <qi.z.zhang@intel.com>
> ---
> v2:
> - fix build warning
> 
>  drivers/net/ice/ice_rxtx.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c index
> 560c1a4af7..cd0e61c85f 100644
> --- a/drivers/net/ice/ice_rxtx.c
> +++ b/drivers/net/ice/ice_rxtx.c
> @@ -3669,9 +3669,6 @@ ice_prep_pkts(__rte_unused void *tx_queue,
> struct rte_mbuf **tx_pkts,
>  	int i, ret;
>  	uint64_t ol_flags;
>  	struct rte_mbuf *m;
> -	struct ice_tx_queue *txq = tx_queue;
> -	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
> -	uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
> 
>  	for (i = 0; i < nb_pkts; i++) {
>  		m = tx_pkts[i];
> @@ -3690,7 +3687,7 @@ ice_prep_pkts(__rte_unused void *tx_queue,
> struct rte_mbuf **tx_pkts,
> 
>  		/* check the data_len in mbuf */
>  		if (m->data_len < ICE_TX_MIN_PKT_LEN ||
> -			m->data_len > max_frame_size) {
> +			m->data_len > ICE_FRAME_SIZE_MAX) {

This is wrong, actually check max_frame_size guarantee the data_len not exceed the buffer size.

Rejected.

>  			rte_errno = EINVAL;
>  			PMD_DRV_LOG(ERR, "INVALID mbuf: bad
> data_len=[%hu]", m->data_len);
>  			return i;
> --
> 2.31.1
  

Patch

diff --git a/drivers/net/ice/ice_rxtx.c b/drivers/net/ice/ice_rxtx.c
index 560c1a4af7..cd0e61c85f 100644
--- a/drivers/net/ice/ice_rxtx.c
+++ b/drivers/net/ice/ice_rxtx.c
@@ -3669,9 +3669,6 @@  ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 	int i, ret;
 	uint64_t ol_flags;
 	struct rte_mbuf *m;
-	struct ice_tx_queue *txq = tx_queue;
-	struct rte_eth_dev *dev = &rte_eth_devices[txq->port_id];
-	uint16_t max_frame_size = dev->data->mtu + ICE_ETH_OVERHEAD;
 
 	for (i = 0; i < nb_pkts; i++) {
 		m = tx_pkts[i];
@@ -3690,7 +3687,7 @@  ice_prep_pkts(__rte_unused void *tx_queue, struct rte_mbuf **tx_pkts,
 
 		/* check the data_len in mbuf */
 		if (m->data_len < ICE_TX_MIN_PKT_LEN ||
-			m->data_len > max_frame_size) {
+			m->data_len > ICE_FRAME_SIZE_MAX) {
 			rte_errno = EINVAL;
 			PMD_DRV_LOG(ERR, "INVALID mbuf: bad data_len=[%hu]", m->data_len);
 			return i;