Skip to contentSkip to conversation

net/idpf: fix crash when launching l3fwd

PATCH Superseded [email protected] 4 participants 7 messages Nov 17, 2022 – Nov 18, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/idpf: fix crash when launching l3fwd

From: Beilei Xing <[email protected]>

There's core dump when launching l3fwd with 1 queue 1 core. It's because NULL pointer is used if fail to configure device. This patch removes incorrect check during device configuration, and checks NULL pointer when excuting VIRTCHNL2_OP_DEALLOC_VECTORS.

Fixes 549343c25db8 ("net/idpf: support device initialization")
Fixes 70675bcc3a57 ("net/idpf: support RSS")
Fixes 37291a68fd78 ("net/idpf: support write back based on ITR expire")
---
 drivers/net/idpf/idpf_ethdev.c | 7 -------
 drivers/net/idpf/idpf_vchnl.c  | 3 +++
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/net/idpf/idpf_ethdev.c +0 -7
index 20f088eb80..51fc97bf7b 100644
@@ -372,13 +372,6 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) ||
-	    (dev->data->nb_rx_queues > 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_RSS)) {
-		PMD_INIT_LOG(ERR, "Multi-queue packet distribution mode %d is not supported",
-			     conf->rxmode.mq_mode);
-		return -ENOTSUP;
-	}
-
 	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
 		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not supported",
 			     conf->txmode.mq_mode);
drivers/net/idpf/idpf_vchnl.c +3 -0
index ac6486d4ef..88770447f8 100644
@@ -1197,6 +1197,9 @@ idpf_vc_dealloc_vectors(struct idpf_vport *vport)
 	int err, len;
 
 	alloc_vec = vport->recv_vectors;
+	if (alloc_vec == NULL)
+		return -EINVAL;
+
 	vcs = &alloc_vec->vchunks;
 
 	len = sizeof(struct virtchnl2_vector_chunks) +
Signature · 1 line
2.26.2
#1 lore raw

PATCH v2 1/1 net/idpf: fix crash when launching l3fwd

From: Beilei Xing <[email protected]>

There's core dump when launching l3fwd with 1 queue 1 core. It's because NULL pointer is used if fail to configure device. This patch removes incorrect check during device configuration, and checks NULL pointer when executing VIRTCHNL2_OP_DEALLOC_VECTORS.

Fixes 549343c25db8 ("net/idpf: support device initialization")
Fixes 70675bcc3a57 ("net/idpf: support RSS")
Fixes 37291a68fd78 ("net/idpf: support write back based on ITR expire")

---
v2 change: Fix typo.

 drivers/net/idpf/idpf_ethdev.c | 7 -------
 drivers/net/idpf/idpf_vchnl.c  | 3 +++
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/net/idpf/idpf_ethdev.c +0 -7
index 20f088eb80..51fc97bf7b 100644
@@ -372,13 +372,6 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) ||
-	    (dev->data->nb_rx_queues > 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_RSS)) {
-		PMD_INIT_LOG(ERR, "Multi-queue packet distribution mode %d is not supported",
-			     conf->rxmode.mq_mode);
-		return -ENOTSUP;
-	}
-
 	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
 		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not supported",
 			     conf->txmode.mq_mode);
drivers/net/idpf/idpf_vchnl.c +3 -0
index ac6486d4ef..88770447f8 100644
@@ -1197,6 +1197,9 @@ idpf_vc_dealloc_vectors(struct idpf_vport *vport)
 	int err, len;
 
 	alloc_vec = vport->recv_vectors;
+	if (alloc_vec == NULL)
+		return -EINVAL;
+
 	vcs = &alloc_vec->vchunks;
 
 	len = sizeof(struct virtchnl2_vector_chunks) +
Signature · 1 line
2.26.2
#2 lore raw
Quoted 9 lines
drivers/net/idpf/idpf_ethdev.c +0 -1
-
 	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
 		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not supported",
 			     conf->txmode.mq_mode);
drivers/net/idpf/idpf_vchnl.c +0 -0
index ac6486d4ef..88770447f8 100644

drivers/net/idpf/idpf_vchnl.c idpf_vc_dealloc_vectors(struct idpf_vport *vport) · line 1202

Quoted 6 lines
drivers/net/idpf/idpf_vchnl.c +3 -0
@@ -1197,6 +1197,9 @@ idpf_vc_dealloc_vectors(struct idpf_vport *vport)
 	int err, len;
 
 	alloc_vec = vport->recv_vectors;
+	if (alloc_vec == NULL)
+		return -EINVAL;
+

Would it be better to check before idpf_vc_dealloc_vectors?

#3 lore raw
Quoted 21 lines

-----Original Message-----
From: Wu, Jingjing <[email protected]>
Sent: Friday, November 18, 2022 2:24 PM
To: Xing, Beilei <[email protected]>
Cc: [email protected]; Peng, Yuan <[email protected]>
Subject: RE: [PATCH v2] net/idpf: fix crash when launching l3fwd

drivers/net/idpf/idpf_ethdev.c idpf_dev_configure(struct rte_eth_dev *dev)

Quoted 3 lines
drivers/net/idpf/idpf_ethdev.c +0 -1
-
 	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
 		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not

supported",

Quoted 8 lines
drivers/net/idpf/idpf_ethdev.c +0 -0
 			     conf->txmode.mq_mode);
(quoted diff) +0 -0

b/drivers/net/idpf/idpf_vchnl.c index ac6486d4ef..88770447f8 100644

drivers/net/idpf/idpf_vchnl.c +0 -0
@@ -1197,6 +1197,9 @@ idpf_vc_dealloc_vectors(struct idpf_vport *vport)
 	int err, len;
 
Quoted 5 lines

drivers/net/idpf/idpf_vchnl.c idpf_vc_dealloc_vectors(struct idpf_vport *vport) · line 1202

Quoted 4 lines
drivers/net/idpf/idpf_vchnl.c +3 -0
 	alloc_vec = vport->recv_vectors;
+	if (alloc_vec == NULL)
+		return -EINVAL;
+

Would it be better to check before idpf_vc_dealloc_vectors?

Make sense, will update in next version.

#4 lore raw

PATCH v3 1/1 net/idpf: fix crash when launching l3fwd

In reply to [email protected]

From: Beilei Xing <[email protected]>

There's core dump when launching l3fwd with 1 queue 1 core. It's because NULL pointer is used if fail to configure device. This patch removes incorrect check during device configuration, and checks NULL pointer when executing VIRTCHNL2_OP_DEALLOC_VECTORS.

Fixes 549343c25db8 ("net/idpf: support device initialization")
Fixes 70675bcc3a57 ("net/idpf: support RSS")
Fixes 37291a68fd78 ("net/idpf: support write back based on ITR expire")

---
v2 change: fix typo.
v3 change: check NULL pointer before virtual channel handling.

 drivers/net/idpf/idpf_ethdev.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/net/idpf/idpf_ethdev.c +2 -8
index 20f088eb80..491ef966a7 100644
@@ -372,13 +372,6 @@ idpf_dev_configure(struct rte_eth_dev *dev)
 		return -ENOTSUP;
 	}
 
-	if ((dev->data->nb_rx_queues == 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_NONE) ||
-	    (dev->data->nb_rx_queues > 1 && conf->rxmode.mq_mode != RTE_ETH_MQ_RX_RSS)) {
-		PMD_INIT_LOG(ERR, "Multi-queue packet distribution mode %d is not supported",
-			     conf->rxmode.mq_mode);
-		return -ENOTSUP;
-	}
-
 	if (conf->txmode.mq_mode != RTE_ETH_MQ_TX_NONE) {
 		PMD_INIT_LOG(ERR, "Multi-queue TX mode %d is not supported",
 			     conf->txmode.mq_mode);
@@ -620,7 +613,8 @@ idpf_dev_stop(struct rte_eth_dev *dev)
 
 	idpf_vc_config_irq_map_unmap(vport, false);
 
-	idpf_vc_dealloc_vectors(vport);
+	if (vport->recv_vectors != NULL)
+		idpf_vc_dealloc_vectors(vport);
 
 	vport->stopped = 1;
 
Signature · 1 line
2.26.2
Acked-by on v3 1/1 Applied
#5 lore raw
Quoted 17 lines

-----Original Message-----
From: [email protected] <[email protected]>
Sent: Friday, November 18, 2022 3:03 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Peng, Yuan <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH v3] net/idpf: fix crash when launching l3fwd

From: Beilei Xing <[email protected]>

There's core dump when launching l3fwd with 1 queue 1 core. It's because NULL pointer is used if fail to configure device.
This patch removes incorrect check during device configuration, and checks NULL pointer when executing VIRTCHNL2_OP_DEALLOC_VECTORS.

Quoted 5 lines
Fixes 549343c25db8 ("net/idpf: support device initialization")
Fixes 70675bcc3a57 ("net/idpf: support RSS")
Fixes 37291a68fd78 ("net/idpf: support write back based on ITR expire")

Applied to dpdk-next-net-intel.

Thanks
Qi

Tested-by on v3 1/1
#6 lore raw
In reply to [email protected]
Quoted 16 lines

-----Original Message-----
From: Xing, Beilei <[email protected]>
Sent: Friday, November 18, 2022 3:03 PM
To: Wu, Jingjing <[email protected]>
Cc: [email protected]; Peng, Yuan <[email protected]>; Xing, Beilei <[email protected]>
Subject: [PATCH v3] net/idpf: fix crash when launching l3fwd

From: Beilei Xing <[email protected]>

There's core dump when launching l3fwd with 1 queue 1 core. It's because NULL pointer is used if fail to configure device.
This patch removes incorrect check during device configuration, and checks NULL pointer when executing VIRTCHNL2_OP_DEALLOC_VECTORS.

Quoted 5 lines
Fixes 549343c25db8 ("net/idpf: support device initialization")
Fixes 70675bcc3a57 ("net/idpf: support RSS")
Fixes 37291a68fd78 ("net/idpf: support write back based on ITR expire")