DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] bus/fslmc: fix use after rte_free
@ 2024-12-18 17:05 Stephen Hemminger
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
  2024-12-23 10:23 ` [PATCH] bus/fslmc: fix use after rte_free Hemant Agrawal
  0 siblings, 2 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-18 17:05 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, shreyansh.jain, stable, Hemant Agrawal, Sachin Saxena

The cleanup loop would derefence the dpio_dev after freeing.
Use TAILQ_FOREACH_SAFE to fix that.
Found by building with sanitizer undefined flag.

Fixes: e55d0494ab98 ("bus/fslmc: support secondary process")
Cc: shreyansh.jain@nxp.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 2dfcf7a498..fb7d1968d1 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -403,6 +403,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	struct rte_dpaa2_device *obj)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
+	struct dpaa2_dpio_dev *dpio_tmp;
 	struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
 	struct qbman_swp_desc p_des;
 	struct dpio_attr attr;
@@ -588,7 +589,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	rte_free(dpio_dev);
 
 	/* For each element in the list, cleanup */
-	TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
+	RTE_TAILQ_FOREACH_SAFE(dpio_dev, &dpio_dev_list, next, dpio_tmp) {
 		if (dpio_dev->dpio) {
 			dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
 				dpio_dev->token);
-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined
  2024-12-18 17:05 [PATCH] bus/fslmc: fix use after rte_free Stephen Hemminger
@ 2024-12-19 22:49 ` Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 1/5] bus/fslmc: fix use after rte_free Stephen Hemminger
                     ` (4 more replies)
  2024-12-23 10:23 ` [PATCH] bus/fslmc: fix use after rte_free Hemant Agrawal
  1 sibling, 5 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-19 22:49 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger

Recent bug report https://bugs.dpdk.org/show_bug.cgi?id=1605
highlighted that no build is done with -Dsanitize=address,undefined.
Doing a test build showed some new issues that were not being reported.

Note: a couple of these required introducing the equivalent _FOREACH_SAFE
variant macros. These are in FreeBSD and in DPDK windows versions of queue.h
but never made it to Linux sys/queue.h. Put the macro in the file where
used (rather than a common spot) to make backporting the fixes easier.

Stephen Hemminger (5):
  bus/fslmc: fix use after rte_free
  net/bnxt: fix use after free
  net/bnx2x: use RTE_BIT32
  net/qede: fix use after free
  vhost: use strlcpy instead of strncpy

 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c |   3 +-
 drivers/net/bnx2x/ecore_reg.h            | 130 +++++++++++------------
 drivers/net/bnxt/bnxt_filter.c           |  11 +-
 drivers/net/qede/qede_filter.c           |  20 ++--
 lib/vhost/socket.c                       |   3 +-
 5 files changed, 90 insertions(+), 77 deletions(-)

-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 1/5] bus/fslmc: fix use after rte_free
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
@ 2024-12-19 22:49   ` Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 2/5] net/bnxt: fix use after free Stephen Hemminger
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-19 22:49 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, shreyansh.jain, stable, Hemant Agrawal, Sachin Saxena

The cleanup loop would deference the dpio_dev after freeing.
Use TAILQ_FOREACH_SAFE to fix that.
Found by building with sanitizer undefined flag.

Fixes: e55d0494ab98 ("bus/fslmc: support secondary process")
Cc: shreyansh.jain@nxp.com
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 2dfcf7a498..fb7d1968d1 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -403,6 +403,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	struct rte_dpaa2_device *obj)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
+	struct dpaa2_dpio_dev *dpio_tmp;
 	struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
 	struct qbman_swp_desc p_des;
 	struct dpio_attr attr;
@@ -588,7 +589,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	rte_free(dpio_dev);
 
 	/* For each element in the list, cleanup */
-	TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
+	RTE_TAILQ_FOREACH_SAFE(dpio_dev, &dpio_dev_list, next, dpio_tmp) {
 		if (dpio_dev->dpio) {
 			dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
 				dpio_dev->token);
-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 2/5] net/bnxt: fix use after free
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 1/5] bus/fslmc: fix use after rte_free Stephen Hemminger
@ 2024-12-19 22:49   ` Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 3/5] net/bnx2x: use RTE_BIT32 Stephen Hemminger
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-19 22:49 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, ajit.khaparde, stable, Somnath Kotur, Kalesh AP

The filter cleanup loop was using STAILQ_FOREACH and rte_free
and would dereference the filter after free.

Found by build with -Dbsanitize=address,undefined

Fixes: e8fe0e067b68 ("net/bnxt: fix allocation of PF info struct")
Cc: ajit.khaparde@broadcom.com
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnxt/bnxt_filter.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/bnxt/bnxt_filter.c b/drivers/net/bnxt/bnxt_filter.c
index 7b90ba651f..3804a5ec16 100644
--- a/drivers/net/bnxt/bnxt_filter.c
+++ b/drivers/net/bnxt/bnxt_filter.c
@@ -12,6 +12,13 @@
 #include <rte_flow_driver.h>
 #include <rte_tailq.h>
 
+#ifndef STAILQ_FOREACH_SAFE
+#define	STAILQ_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = STAILQ_FIRST((head));				\
+	    (var) && ((tvar) = STAILQ_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+#endif
+
 #include "bnxt.h"
 #include "bnxt_filter.h"
 #include "bnxt_hwrm.h"
@@ -151,7 +158,9 @@ void bnxt_free_filter_mem(struct bnxt *bp)
 	bp->filter_info = NULL;
 
 	for (i = 0; i < bp->pf->max_vfs; i++) {
-		STAILQ_FOREACH(filter, &bp->pf->vf_info[i].filter, next) {
+		struct bnxt_filter_info *tmp;
+
+		STAILQ_FOREACH_SAFE(filter, &bp->pf->vf_info[i].filter, next, tmp) {
 			rte_free(filter);
 			STAILQ_REMOVE(&bp->pf->vf_info[i].filter, filter,
 				      bnxt_filter_info, next);
-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 3/5] net/bnx2x: use RTE_BIT32
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 1/5] bus/fslmc: fix use after rte_free Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 2/5] net/bnxt: fix use after free Stephen Hemminger
@ 2024-12-19 22:49   ` Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 4/5] net/qede: fix use after free Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Stephen Hemminger
  4 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-19 22:49 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Julien Aube

The expression "0x1 << 31" is actually undefined since 0x1
is an integer not unsigned. Fix the general problem by using
the existing RTE_BIT32() macros instead.

Shows up as a cryptic warning when building with -Dbsanitize=undefined.

../drivers/net/bnx2x/bnx2x.c:3362:25: error: case label does not reduce to an integer constant
 3362 |                         case AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY:
      |                         ^~~~

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/bnx2x/ecore_reg.h | 130 +++++++++++++++++-----------------
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/drivers/net/bnx2x/ecore_reg.h b/drivers/net/bnx2x/ecore_reg.h
index 6f7b0522f2..bddea3b832 100644
--- a/drivers/net/bnx2x/ecore_reg.h
+++ b/drivers/net/bnx2x/ecore_reg.h
@@ -4359,71 +4359,71 @@
 #define HW_LOCK_RESOURCE_RECOVERY_REG				 11
 #define HW_LOCK_RESOURCE_RESET					 5
 #define HW_LOCK_RESOURCE_SPIO					 2
-#define AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT			 (0x1 << 4)
-#define AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR			 (0x1 << 5)
-#define AEU_INPUTS_ATTN_BITS_BRB_HW_INTERRUPT			 (0x1 << 19)
-#define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR			 (0x1 << 18)
-#define AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT			 (0x1 << 31)
-#define AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR			 (0x1 << 30)
-#define AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT			 (0x1 << 9)
-#define AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR			 (0x1 << 8)
-#define AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT			 (0x1 << 7)
-#define AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR			 (0x1 << 6)
-#define AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT			 (0x1 << 29)
-#define AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR			 (0x1 << 28)
-#define AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT			 (0x1 << 1)
-#define AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR			 (0x1 << 0)
-#define AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR			 (0x1 << 18)
-#define AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT			 (0x1 << 11)
-#define AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR			 (0x1 << 10)
-#define AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT		 (0x1 << 13)
-#define AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR		 (0x1 << 12)
-#define AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0			 (0x1 << 2)
-#define AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR			 (0x1 << 12)
-#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY		 (0x1 << 28)
-#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY		 (0x1 << 31)
-#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY		 (0x1 << 29)
-#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY		 (0x1 << 30)
-#define AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT			 (0x1 << 15)
-#define AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR			 (0x1 << 14)
-#define AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR			 (0x1 << 14)
-#define AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR		 (0x1 << 20)
-#define AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT		 (0x1 << 31)
-#define AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR		 (0x1 << 30)
-#define AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR			 (0x1 << 0)
-#define AEU_INPUTS_ATTN_BITS_PGLUE_HW_INTERRUPT			 (0x1 << 2)
-#define AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR			 (0x1 << 3)
-#define AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT	 (0x1 << 5)
-#define AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR	 (0x1 << 4)
-#define AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT			 (0x1 << 3)
-#define AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR			 (0x1 << 2)
-#define AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT			 (0x1 << 3)
-#define AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR			 (0x1 << 2)
-#define AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR		 (0x1 << 22)
-#define AEU_INPUTS_ATTN_BITS_SPIO5				 (0x1 << 15)
-#define AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT			 (0x1 << 27)
-#define AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR			 (0x1 << 26)
-#define AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT		 (0x1 << 5)
-#define AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR		 (0x1 << 4)
-#define AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT			 (0x1 << 25)
-#define AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR			 (0x1 << 24)
-#define AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT			 (0x1 << 29)
-#define AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR			 (0x1 << 28)
-#define AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT			 (0x1 << 23)
-#define AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR			 (0x1 << 22)
-#define AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT			 (0x1 << 27)
-#define AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR			 (0x1 << 26)
-#define AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT			 (0x1 << 21)
-#define AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR			 (0x1 << 20)
-#define AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT			 (0x1 << 25)
-#define AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR			 (0x1 << 24)
-#define AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR		 (0x1 << 16)
-#define AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT			 (0x1 << 9)
-#define AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR			 (0x1 << 8)
-#define AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT			 (0x1 << 7)
-#define AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR			 (0x1 << 6)
-#define AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT			 (0x1 << 11)
-#define AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR			 (0x1 << 10)
+#define AEU_INPUTS_ATTN_BITS_ATC_HW_INTERRUPT			 RTE_BIT32(4)
+#define AEU_INPUTS_ATTN_BITS_ATC_PARITY_ERROR			 RTE_BIT32(5)
+#define AEU_INPUTS_ATTN_BITS_BRB_HW_INTERRUPT			 RTE_BIT32(19)
+#define AEU_INPUTS_ATTN_BITS_BRB_PARITY_ERROR			 RTE_BIT32(18)
+#define AEU_INPUTS_ATTN_BITS_CCM_HW_INTERRUPT			 RTE_BIT32(31)
+#define AEU_INPUTS_ATTN_BITS_CCM_PARITY_ERROR			 RTE_BIT32(30)
+#define AEU_INPUTS_ATTN_BITS_CDU_HW_INTERRUPT			 RTE_BIT32(9)
+#define AEU_INPUTS_ATTN_BITS_CDU_PARITY_ERROR			 RTE_BIT32(8)
+#define AEU_INPUTS_ATTN_BITS_CFC_HW_INTERRUPT			 RTE_BIT32(7)
+#define AEU_INPUTS_ATTN_BITS_CFC_PARITY_ERROR			 RTE_BIT32(6)
+#define AEU_INPUTS_ATTN_BITS_CSDM_HW_INTERRUPT			 RTE_BIT32(29)
+#define AEU_INPUTS_ATTN_BITS_CSDM_PARITY_ERROR			 RTE_BIT32(28)
+#define AEU_INPUTS_ATTN_BITS_CSEMI_HW_INTERRUPT			 RTE_BIT32(1)
+#define AEU_INPUTS_ATTN_BITS_CSEMI_PARITY_ERROR			 RTE_BIT32(0)
+#define AEU_INPUTS_ATTN_BITS_DEBUG_PARITY_ERROR			 RTE_BIT32(18)
+#define AEU_INPUTS_ATTN_BITS_DMAE_HW_INTERRUPT			 RTE_BIT32(11)
+#define AEU_INPUTS_ATTN_BITS_DMAE_PARITY_ERROR			 RTE_BIT32(10)
+#define AEU_INPUTS_ATTN_BITS_DOORBELLQ_HW_INTERRUPT		 RTE_BIT32(13)
+#define AEU_INPUTS_ATTN_BITS_DOORBELLQ_PARITY_ERROR		 RTE_BIT32(12)
+#define AEU_INPUTS_ATTN_BITS_GPIO0_FUNCTION_0			 RTE_BIT32(2)
+#define AEU_INPUTS_ATTN_BITS_IGU_PARITY_ERROR			 RTE_BIT32(12)
+#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_ROM_PARITY		 RTE_BIT32(28)
+#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_SCPAD_PARITY		 RTE_BIT32(31)
+#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_RX_PARITY		 RTE_BIT32(29)
+#define AEU_INPUTS_ATTN_BITS_MCP_LATCHED_UMP_TX_PARITY		 RTE_BIT32(30)
+#define AEU_INPUTS_ATTN_BITS_MISC_HW_INTERRUPT			 RTE_BIT32(15)
+#define AEU_INPUTS_ATTN_BITS_MISC_PARITY_ERROR			 RTE_BIT32(14)
+#define AEU_INPUTS_ATTN_BITS_NIG_PARITY_ERROR			 RTE_BIT32(14)
+#define AEU_INPUTS_ATTN_BITS_PARSER_PARITY_ERROR		 RTE_BIT32(20)
+#define AEU_INPUTS_ATTN_BITS_PBCLIENT_HW_INTERRUPT		 RTE_BIT32(31)
+#define AEU_INPUTS_ATTN_BITS_PBCLIENT_PARITY_ERROR		 RTE_BIT32(30)
+#define AEU_INPUTS_ATTN_BITS_PBF_PARITY_ERROR			 RTE_BIT32(0)
+#define AEU_INPUTS_ATTN_BITS_PGLUE_HW_INTERRUPT			 RTE_BIT32(2)
+#define AEU_INPUTS_ATTN_BITS_PGLUE_PARITY_ERROR			 RTE_BIT32(3)
+#define AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_HW_INTERRUPT	 RTE_BIT32(5)
+#define AEU_INPUTS_ATTN_BITS_PXPPCICLOCKCLIENT_PARITY_ERROR	 RTE_BIT32(4)
+#define AEU_INPUTS_ATTN_BITS_PXP_HW_INTERRUPT			 RTE_BIT32(3)
+#define AEU_INPUTS_ATTN_BITS_PXP_PARITY_ERROR			 RTE_BIT32(2)
+#define AEU_INPUTS_ATTN_BITS_QM_HW_INTERRUPT			 RTE_BIT32(3)
+#define AEU_INPUTS_ATTN_BITS_QM_PARITY_ERROR			 RTE_BIT32(2)
+#define AEU_INPUTS_ATTN_BITS_SEARCHER_PARITY_ERROR		 RTE_BIT32(22)
+#define AEU_INPUTS_ATTN_BITS_SPIO5				 RTE_BIT32(15)
+#define AEU_INPUTS_ATTN_BITS_TCM_HW_INTERRUPT			 RTE_BIT32(27)
+#define AEU_INPUTS_ATTN_BITS_TCM_PARITY_ERROR			 RTE_BIT32(26)
+#define AEU_INPUTS_ATTN_BITS_TIMERS_HW_INTERRUPT		 RTE_BIT32(5)
+#define AEU_INPUTS_ATTN_BITS_TIMERS_PARITY_ERROR		 RTE_BIT32(4)
+#define AEU_INPUTS_ATTN_BITS_TSDM_HW_INTERRUPT			 RTE_BIT32(25)
+#define AEU_INPUTS_ATTN_BITS_TSDM_PARITY_ERROR			 RTE_BIT32(24)
+#define AEU_INPUTS_ATTN_BITS_TSEMI_HW_INTERRUPT			 RTE_BIT32(29)
+#define AEU_INPUTS_ATTN_BITS_TSEMI_PARITY_ERROR			 RTE_BIT32(28)
+#define AEU_INPUTS_ATTN_BITS_UCM_HW_INTERRUPT			 RTE_BIT32(23)
+#define AEU_INPUTS_ATTN_BITS_UCM_PARITY_ERROR			 RTE_BIT32(22)
+#define AEU_INPUTS_ATTN_BITS_UPB_HW_INTERRUPT			 RTE_BIT32(27)
+#define AEU_INPUTS_ATTN_BITS_UPB_PARITY_ERROR			 RTE_BIT32(26)
+#define AEU_INPUTS_ATTN_BITS_USDM_HW_INTERRUPT			 RTE_BIT32(21)
+#define AEU_INPUTS_ATTN_BITS_USDM_PARITY_ERROR			 RTE_BIT32(20)
+#define AEU_INPUTS_ATTN_BITS_USEMI_HW_INTERRUPT			 RTE_BIT32(25)
+#define AEU_INPUTS_ATTN_BITS_USEMI_PARITY_ERROR			 RTE_BIT32(24)
+#define AEU_INPUTS_ATTN_BITS_VAUX_PCI_CORE_PARITY_ERROR		 RTE_BIT32(16)
+#define AEU_INPUTS_ATTN_BITS_XCM_HW_INTERRUPT			 RTE_BIT32(9)
+#define AEU_INPUTS_ATTN_BITS_XCM_PARITY_ERROR			 RTE_BIT32(8)
+#define AEU_INPUTS_ATTN_BITS_XSDM_HW_INTERRUPT			 RTE_BIT32(7)
+#define AEU_INPUTS_ATTN_BITS_XSDM_PARITY_ERROR			 RTE_BIT32(6)
+#define AEU_INPUTS_ATTN_BITS_XSEMI_HW_INTERRUPT			 RTE_BIT32(11)
+#define AEU_INPUTS_ATTN_BITS_XSEMI_PARITY_ERROR			 RTE_BIT32(10)
 #define RESERVED_GENERAL_ATTENTION_BIT_0	0
 
 #define EVEREST_GEN_ATTN_IN_USE_MASK		0x7ffe0
-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 4/5] net/qede: fix use after free
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
                     ` (2 preceding siblings ...)
  2024-12-19 22:49   ` [PATCH v2 3/5] net/bnx2x: use RTE_BIT32 Stephen Hemminger
@ 2024-12-19 22:49   ` Stephen Hemminger
  2024-12-19 22:49   ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Stephen Hemminger
  4 siblings, 0 replies; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-19 22:49 UTC (permalink / raw)
  To: dev
  Cc: Stephen Hemminger, shahed.shaikh, stable, Devendra Singh Rawat,
	Alok Prasad, Shahed Shaikh

The loop cleaning up flowdir resources was using SLIST_FOREACH
but the inner loop would call rte_free. Found by building with
address sanitizer undefined check.

Also remove needless initialization, and null check.

Fixes: f5765f66f9bb ("net/qede: refactor flow director into generic aRFS")
Cc: shahed.shaikh@cavium.com
Cc: stable@dpdk.org

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 drivers/net/qede/qede_filter.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/drivers/net/qede/qede_filter.c b/drivers/net/qede/qede_filter.c
index 14fb4338e9..5db36b03e2 100644
--- a/drivers/net/qede/qede_filter.c
+++ b/drivers/net/qede/qede_filter.c
@@ -10,6 +10,13 @@
 #include <rte_errno.h>
 #include <rte_flow_driver.h>
 
+#ifndef SLIST_FOREACH_SAFE
+#define	SLIST_FOREACH_SAFE(var, head, field, tvar)			\
+	for ((var) = SLIST_FIRST((head));				\
+	    (var) && ((tvar) = SLIST_NEXT((var), field), 1);		\
+	    (var) = (tvar))
+#endif
+
 #include "qede_ethdev.h"
 
 /* VXLAN tunnel classification mapping */
@@ -154,15 +161,12 @@ int qede_check_fdir_support(struct rte_eth_dev *eth_dev)
 void qede_fdir_dealloc_resc(struct rte_eth_dev *eth_dev)
 {
 	struct qede_dev *qdev = QEDE_INIT_QDEV(eth_dev);
-	struct qede_arfs_entry *tmp = NULL;
+	struct qede_arfs_entry *tmp, *tmp2;
 
-	SLIST_FOREACH(tmp, &qdev->arfs_info.arfs_list_head, list) {
-		if (tmp) {
-			rte_memzone_free(tmp->mz);
-			SLIST_REMOVE(&qdev->arfs_info.arfs_list_head, tmp,
-				     qede_arfs_entry, list);
-			rte_free(tmp);
-		}
+	SLIST_FOREACH_SAFE(tmp, &qdev->arfs_info.arfs_list_head, list, tmp2) {
+		rte_memzone_free(tmp->mz);
+		SLIST_REMOVE(&qdev->arfs_info.arfs_list_head, tmp, qede_arfs_entry, list);
+		rte_free(tmp);
 	}
 }
 
-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v2 5/5] vhost: use strlcpy instead of strncpy
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
                     ` (3 preceding siblings ...)
  2024-12-19 22:49   ` [PATCH v2 4/5] net/qede: fix use after free Stephen Hemminger
@ 2024-12-19 22:49   ` Stephen Hemminger
  2024-12-20 13:37     ` Bruce Richardson
  4 siblings, 1 reply; 9+ messages in thread
From: Stephen Hemminger @ 2024-12-19 22:49 UTC (permalink / raw)
  To: dev; +Cc: Stephen Hemminger, Maxime Coquelin, Chenbo Xia

Some tools such as gcc address sanitizer will complain if strncpy
is used to completely fill a string since it will not be null
terminated. Since the previous code forced as null at end,
use strlcpy() to get the same effect.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/vhost/socket.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
index d29d15494c..f938189cc2 100644
--- a/lib/vhost/socket.c
+++ b/lib/vhost/socket.c
@@ -359,8 +359,7 @@ create_unix_socket(struct vhost_user_socket *vsocket)
 
 	memset(un, 0, sizeof(*un));
 	un->sun_family = AF_UNIX;
-	strncpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
-	un->sun_path[sizeof(un->sun_path) - 1] = '\0';
+	strlcpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
 
 	vsocket->socket_fd = fd;
 	return 0;
-- 
2.45.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2 5/5] vhost: use strlcpy instead of strncpy
  2024-12-19 22:49   ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Stephen Hemminger
@ 2024-12-20 13:37     ` Bruce Richardson
  0 siblings, 0 replies; 9+ messages in thread
From: Bruce Richardson @ 2024-12-20 13:37 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Maxime Coquelin, Chenbo Xia

On Thu, Dec 19, 2024 at 02:49:55PM -0800, Stephen Hemminger wrote:
> Some tools such as gcc address sanitizer will complain if strncpy
> is used to completely fill a string since it will not be null
> terminated. Since the previous code forced as null at end,
> use strlcpy() to get the same effect.
> 
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
>  lib/vhost/socket.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/lib/vhost/socket.c b/lib/vhost/socket.c
> index d29d15494c..f938189cc2 100644
> --- a/lib/vhost/socket.c
> +++ b/lib/vhost/socket.c
> @@ -359,8 +359,7 @@ create_unix_socket(struct vhost_user_socket *vsocket)
>  
>  	memset(un, 0, sizeof(*un));
>  	un->sun_family = AF_UNIX;
> -	strncpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
> -	un->sun_path[sizeof(un->sun_path) - 1] = '\0';
> +	strlcpy(un->sun_path, vsocket->path, sizeof(un->sun_path));
>  

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* RE: [PATCH] bus/fslmc: fix use after rte_free
  2024-12-18 17:05 [PATCH] bus/fslmc: fix use after rte_free Stephen Hemminger
  2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
@ 2024-12-23 10:23 ` Hemant Agrawal
  1 sibling, 0 replies; 9+ messages in thread
From: Hemant Agrawal @ 2024-12-23 10:23 UTC (permalink / raw)
  To: Stephen Hemminger, dev; +Cc: shreyansh.jain, stable, Sachin Saxena

Acked-by: Hemant Agrawal <hemant.agrawal@nxp.com>

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-12-23 10:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-18 17:05 [PATCH] bus/fslmc: fix use after rte_free Stephen Hemminger
2024-12-19 22:49 ` [PATCH v2 0/5] Fixes for build with -Dsanitize=undefined Stephen Hemminger
2024-12-19 22:49   ` [PATCH v2 1/5] bus/fslmc: fix use after rte_free Stephen Hemminger
2024-12-19 22:49   ` [PATCH v2 2/5] net/bnxt: fix use after free Stephen Hemminger
2024-12-19 22:49   ` [PATCH v2 3/5] net/bnx2x: use RTE_BIT32 Stephen Hemminger
2024-12-19 22:49   ` [PATCH v2 4/5] net/qede: fix use after free Stephen Hemminger
2024-12-19 22:49   ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Stephen Hemminger
2024-12-20 13:37     ` Bruce Richardson
2024-12-23 10:23 ` [PATCH] bus/fslmc: fix use after rte_free Hemant Agrawal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).