* [PATCH v3] app/testpmd: fix heap-free-before-use when quit
2022-02-23 11:32 [PATCH v2 2/2] app/testpmd:fix testpmd quit failure wenxuanx.wu
@ 2022-03-01 7:28 ` wenxuanx.wu
2022-03-02 7:20 ` wenxuanx.wu
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: wenxuanx.wu @ 2022-03-01 7:28 UTC (permalink / raw)
To: yuying.zhang, xiaoyun.li, aman.deep.singh; +Cc: dpdk, wenxuan wu, stable
From: wenxuan wu <wenxuanx.wu@intel.com>
Change func logic is_bonding_slave and set_port_slave_flag to avoid this
error.Port->slave_flag with dev_flag check to ensure slave_flag is securely
set.
Remove eth_dev_info_get in func is_bonding_slave, which would lead to
a heap-free-before-use error the reason is that vf was still accessing a
freed pf resource.
Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
Cc: stable@dpdk.org
Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
---
app/test-pmd/testpmd.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e1da961311..dcba11f7a6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3805,15 +3805,23 @@ init_port_config(void)
}
}
-void set_port_slave_flag(portid_t slave_pid)
+void
+set_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
-
+ struct rte_eth_dev_info dev_info;
+ int ret;
port = &ports[slave_pid];
- port->slave_flag = 1;
+ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+ if (ret != 0)
+ return;
+
+ if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
+ port->slave_flag = 1;
}
-void clear_port_slave_flag(portid_t slave_pid)
+void
+clear_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
@@ -3821,26 +3829,17 @@ void clear_port_slave_flag(portid_t slave_pid)
port->slave_flag = 0;
}
-uint8_t port_is_bonding_slave(portid_t slave_pid)
+uint8_t
+port_is_bonding_slave(portid_t slave_pid)
{
struct rte_port *port;
- struct rte_eth_dev_info dev_info;
- int ret;
-
port = &ports[slave_pid];
- ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
- if (ret != 0) {
- TESTPMD_LOG(ERR,
- "Failed to get device info for port id %d,"
- "cannot determine if the port is a bonded slave",
- slave_pid);
- return 0;
- }
- if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
+ if (port->slave_flag == 1)
return 1;
return 0;
}
+
const uint16_t vlan_tags[] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] app/testpmd: fix heap-free-before-use when quit
2022-02-23 11:32 [PATCH v2 2/2] app/testpmd:fix testpmd quit failure wenxuanx.wu
2022-03-01 7:28 ` [PATCH v3] app/testpmd: fix heap-free-before-use when quit wenxuanx.wu
@ 2022-03-02 7:20 ` wenxuanx.wu
2022-03-02 8:06 ` wenxuanx.wu
2022-03-02 8:34 ` wenxuanx.wu
3 siblings, 0 replies; 5+ messages in thread
From: wenxuanx.wu @ 2022-03-02 7:20 UTC (permalink / raw)
To: aman.deep.singh, yuying.zhang, xiaoyun.li; +Cc: dpdk, wenxuan wu, stable
From: wenxuan wu <wenxuanx.wu@intel.com>
Change func logic is_bonding_slave and set_port_slave_flag to avoid this
error.Port->slave_flag with dev_flag check to ensure slave_flag is securely
set.
Remove eth_dev_info_get in func is_bonding_slave, which would lead to
a heap-free-before-use error the reason is that vf was still accessing a
freed pf resource.
Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
Cc: stable@dpdk.org
Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
---
app/test-pmd/testpmd.c | 33 ++++++++++++++++-----------------
1 file changed, 16 insertions(+), 17 deletions(-)
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e1da961311..dcba11f7a6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3805,15 +3805,23 @@ init_port_config(void)
}
}
-void set_port_slave_flag(portid_t slave_pid)
+void
+set_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
-
+ struct rte_eth_dev_info dev_info;
+ int ret;
port = &ports[slave_pid];
- port->slave_flag = 1;
+ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+ if (ret != 0)
+ return;
+
+ if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
+ port->slave_flag = 1;
}
-void clear_port_slave_flag(portid_t slave_pid)
+void
+clear_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
@@ -3821,26 +3829,17 @@ void clear_port_slave_flag(portid_t slave_pid)
port->slave_flag = 0;
}
-uint8_t port_is_bonding_slave(portid_t slave_pid)
+uint8_t
+port_is_bonding_slave(portid_t slave_pid)
{
struct rte_port *port;
- struct rte_eth_dev_info dev_info;
- int ret;
-
port = &ports[slave_pid];
- ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
- if (ret != 0) {
- TESTPMD_LOG(ERR,
- "Failed to get device info for port id %d,"
- "cannot determine if the port is a bonded slave",
- slave_pid);
- return 0;
- }
- if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
+ if (port->slave_flag == 1)
return 1;
return 0;
}
+
const uint16_t vlan_tags[] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15,
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] app/testpmd: fix heap-free-before-use when quit
2022-02-23 11:32 [PATCH v2 2/2] app/testpmd:fix testpmd quit failure wenxuanx.wu
2022-03-01 7:28 ` [PATCH v3] app/testpmd: fix heap-free-before-use when quit wenxuanx.wu
2022-03-02 7:20 ` wenxuanx.wu
@ 2022-03-02 8:06 ` wenxuanx.wu
2022-03-02 8:34 ` wenxuanx.wu
3 siblings, 0 replies; 5+ messages in thread
From: wenxuanx.wu @ 2022-03-02 8:06 UTC (permalink / raw)
To: aman.deep.singh, yuying.zhang, xiaoyun.li; +Cc: dpdk, wenxuan wu, stable
From: wenxuan wu <wenxuanx.wu@intel.com>
Change func logic is_bonding_slave and set_port_slave_flag to avoid this
error. Port->slave_flag with dev_flag check to ensure slave_flag is securely
set.
Remove eth_dev_info_get in func is_bonding_slave, which would lead to
a heap-free-before-use error the reason is that vf was still accessing a
freed pf resource.
Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
Cc: stable@dpdk.org
Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
---
...d-fix-heap-free-before-use-when-quit.patch | 87 +++++++++++++++++++
app/test-pmd/testpmd.c | 31 +++----
2 files changed, 101 insertions(+), 17 deletions(-)
create mode 100644 0001-app-testpmd-fix-heap-free-before-use-when-quit.patch
diff --git a/0001-app-testpmd-fix-heap-free-before-use-when-quit.patch b/0001-app-testpmd-fix-heap-free-before-use-when-quit.patch
new file mode 100644
index 0000000000..70d7fc8342
--- /dev/null
+++ b/0001-app-testpmd-fix-heap-free-before-use-when-quit.patch
@@ -0,0 +1,87 @@
+From 78fdeab26f9f01bdee1ca5648c1314acb5a4e6fe Mon Sep 17 00:00:00 2001
+From: wenxuan wu <wenxuanx.wu@intel.com>
+Date: Tue, 1 Mar 2022 14:07:37 +0800
+Subject: [DPDK] app/testpmd: fix heap-free-before-use when quit
+
+Change func logic is_bonding_slave and set_port_slave_flag to avoid this
+error.Port->slave_flag with dev_flag check to ensure slave_flag is securely
+set.
+
+Remove eth_dev_info_get in func is_bonding_slave, which would lead to
+a heap-free-before-use error the reason is that vf was still accessing a
+freed pf resource.
+
+Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
+Cc: stable@dpdk.org
+
+Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
+---
+ app/test-pmd/testpmd.c | 33 ++++++++++++++++-----------------
+ 1 file changed, 16 insertions(+), 17 deletions(-)
+
+diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
+index e1da961311..dcba11f7a6 100644
+--- a/app/test-pmd/testpmd.c
++++ b/app/test-pmd/testpmd.c
+@@ -3805,15 +3805,23 @@ init_port_config(void)
+ }
+ }
+
+-void set_port_slave_flag(portid_t slave_pid)
++void
++set_port_slave_flag(portid_t slave_pid)
+ {
+ struct rte_port *port;
+-
++ struct rte_eth_dev_info dev_info;
++ int ret;
+ port = &ports[slave_pid];
+- port->slave_flag = 1;
++ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
++ if (ret != 0)
++ return;
++
++ if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
++ port->slave_flag = 1;
+ }
+
+-void clear_port_slave_flag(portid_t slave_pid)
++void
++clear_port_slave_flag(portid_t slave_pid)
+ {
+ struct rte_port *port;
+
+@@ -3821,26 +3829,17 @@ void clear_port_slave_flag(portid_t slave_pid)
+ port->slave_flag = 0;
+ }
+
+-uint8_t port_is_bonding_slave(portid_t slave_pid)
++uint8_t
++port_is_bonding_slave(portid_t slave_pid)
+ {
+ struct rte_port *port;
+- struct rte_eth_dev_info dev_info;
+- int ret;
+-
+ port = &ports[slave_pid];
+- ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+- if (ret != 0) {
+- TESTPMD_LOG(ERR,
+- "Failed to get device info for port id %d,"
+- "cannot determine if the port is a bonded slave",
+- slave_pid);
+- return 0;
+- }
+- if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
++ if (port->slave_flag == 1)
+ return 1;
+ return 0;
+ }
+
++
+ const uint16_t vlan_tags[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+--
+2.25.1
+
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e1da961311..6f7ad974b6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3805,15 +3805,22 @@ init_port_config(void)
}
}
-void set_port_slave_flag(portid_t slave_pid)
+void
+set_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
-
+ struct rte_eth_dev_info dev_info;
+ int ret;
port = &ports[slave_pid];
- port->slave_flag = 1;
+ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+ if (ret != 0)
+ return;
+ if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
+ port->slave_flag = 1;
}
-void clear_port_slave_flag(portid_t slave_pid)
+void
+clear_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
@@ -3821,22 +3828,12 @@ void clear_port_slave_flag(portid_t slave_pid)
port->slave_flag = 0;
}
-uint8_t port_is_bonding_slave(portid_t slave_pid)
+uint8_t
+port_is_bonding_slave(portid_t slave_pid)
{
struct rte_port *port;
- struct rte_eth_dev_info dev_info;
- int ret;
-
port = &ports[slave_pid];
- ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
- if (ret != 0) {
- TESTPMD_LOG(ERR,
- "Failed to get device info for port id %d,"
- "cannot determine if the port is a bonded slave",
- slave_pid);
- return 0;
- }
- if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
+ if (port->slave_flag == 1)
return 1;
return 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3] app/testpmd: fix heap-free-before-use when quit
2022-02-23 11:32 [PATCH v2 2/2] app/testpmd:fix testpmd quit failure wenxuanx.wu
` (2 preceding siblings ...)
2022-03-02 8:06 ` wenxuanx.wu
@ 2022-03-02 8:34 ` wenxuanx.wu
3 siblings, 0 replies; 5+ messages in thread
From: wenxuanx.wu @ 2022-03-02 8:34 UTC (permalink / raw)
To: aman.deep.singh, yuying.zhang, xiaoyun.li; +Cc: wenxuan wu, stable
From: wenxuan wu <wenxuanx.wu@intel.com>
Change func logic is_bonding_slave and set_port_slave_flag to avoid this
error. Port->slave_flag with dev_flag check to ensure slave_flag is securely
set.
Remove eth_dev_info_get in func is_bonding_slave, which would lead to
a heap-free-before-use error the reason is that vf was still accessing a
freed pf resource.
Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
Cc: stable@dpdk.org
Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
---
...d-fix-heap-free-before-use-when-quit.patch | 87 +++++++++++++++++++
app/test-pmd/testpmd.c | 31 +++----
2 files changed, 101 insertions(+), 17 deletions(-)
create mode 100644 0001-app-testpmd-fix-heap-free-before-use-when-quit.patch
diff --git a/0001-app-testpmd-fix-heap-free-before-use-when-quit.patch b/0001-app-testpmd-fix-heap-free-before-use-when-quit.patch
new file mode 100644
index 0000000000..70d7fc8342
--- /dev/null
+++ b/0001-app-testpmd-fix-heap-free-before-use-when-quit.patch
@@ -0,0 +1,87 @@
+From 78fdeab26f9f01bdee1ca5648c1314acb5a4e6fe Mon Sep 17 00:00:00 2001
+From: wenxuan wu <wenxuanx.wu@intel.com>
+Date: Tue, 1 Mar 2022 14:07:37 +0800
+Subject: [DPDK] app/testpmd: fix heap-free-before-use when quit
+
+Change func logic is_bonding_slave and set_port_slave_flag to avoid this
+error.Port->slave_flag with dev_flag check to ensure slave_flag is securely
+set.
+
+Remove eth_dev_info_get in func is_bonding_slave, which would lead to
+a heap-free-before-use error the reason is that vf was still accessing a
+freed pf resource.
+
+Fixes: 0a0821bcf312 ("app/testpmd: remove most uses of internal ethdev array")
+Cc: stable@dpdk.org
+
+Signed-off-by: Wenxuan Wu <wenxuanx.wu@intel.com>
+---
+ app/test-pmd/testpmd.c | 33 ++++++++++++++++-----------------
+ 1 file changed, 16 insertions(+), 17 deletions(-)
+
+diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
+index e1da961311..dcba11f7a6 100644
+--- a/app/test-pmd/testpmd.c
++++ b/app/test-pmd/testpmd.c
+@@ -3805,15 +3805,23 @@ init_port_config(void)
+ }
+ }
+
+-void set_port_slave_flag(portid_t slave_pid)
++void
++set_port_slave_flag(portid_t slave_pid)
+ {
+ struct rte_port *port;
+-
++ struct rte_eth_dev_info dev_info;
++ int ret;
+ port = &ports[slave_pid];
+- port->slave_flag = 1;
++ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
++ if (ret != 0)
++ return;
++
++ if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
++ port->slave_flag = 1;
+ }
+
+-void clear_port_slave_flag(portid_t slave_pid)
++void
++clear_port_slave_flag(portid_t slave_pid)
+ {
+ struct rte_port *port;
+
+@@ -3821,26 +3829,17 @@ void clear_port_slave_flag(portid_t slave_pid)
+ port->slave_flag = 0;
+ }
+
+-uint8_t port_is_bonding_slave(portid_t slave_pid)
++uint8_t
++port_is_bonding_slave(portid_t slave_pid)
+ {
+ struct rte_port *port;
+- struct rte_eth_dev_info dev_info;
+- int ret;
+-
+ port = &ports[slave_pid];
+- ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+- if (ret != 0) {
+- TESTPMD_LOG(ERR,
+- "Failed to get device info for port id %d,"
+- "cannot determine if the port is a bonded slave",
+- slave_pid);
+- return 0;
+- }
+- if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
++ if (port->slave_flag == 1)
+ return 1;
+ return 0;
+ }
+
++
+ const uint16_t vlan_tags[] = {
+ 0, 1, 2, 3, 4, 5, 6, 7,
+ 8, 9, 10, 11, 12, 13, 14, 15,
+--
+2.25.1
+
diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c
index e1da961311..6f7ad974b6 100644
--- a/app/test-pmd/testpmd.c
+++ b/app/test-pmd/testpmd.c
@@ -3805,15 +3805,22 @@ init_port_config(void)
}
}
-void set_port_slave_flag(portid_t slave_pid)
+void
+set_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
-
+ struct rte_eth_dev_info dev_info;
+ int ret;
port = &ports[slave_pid];
- port->slave_flag = 1;
+ ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
+ if (ret != 0)
+ return;
+ if (*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE)
+ port->slave_flag = 1;
}
-void clear_port_slave_flag(portid_t slave_pid)
+void
+clear_port_slave_flag(portid_t slave_pid)
{
struct rte_port *port;
@@ -3821,22 +3828,12 @@ void clear_port_slave_flag(portid_t slave_pid)
port->slave_flag = 0;
}
-uint8_t port_is_bonding_slave(portid_t slave_pid)
+uint8_t
+port_is_bonding_slave(portid_t slave_pid)
{
struct rte_port *port;
- struct rte_eth_dev_info dev_info;
- int ret;
-
port = &ports[slave_pid];
- ret = eth_dev_info_get_print_err(slave_pid, &dev_info);
- if (ret != 0) {
- TESTPMD_LOG(ERR,
- "Failed to get device info for port id %d,"
- "cannot determine if the port is a bonded slave",
- slave_pid);
- return 0;
- }
- if ((*dev_info.dev_flags & RTE_ETH_DEV_BONDED_SLAVE) || (port->slave_flag == 1))
+ if (port->slave_flag == 1)
return 1;
return 0;
}
--
2.25.1
^ permalink raw reply [flat|nested] 5+ messages in thread