From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
shahed.shaikh@cavium.com, stable@dpdk.org,
Devendra Singh Rawat <dsinghrawat@marvell.com>,
Alok Prasad <palok@marvell.com>,
Shahed Shaikh <shshaikh@marvell.com>
Subject: [PATCH v2 4/5] net/qede: fix use after free
Date: Thu, 19 Dec 2024 14:49:54 -0800 [thread overview]
Message-ID: <20241219225253.782792-5-stephen@networkplumber.org> (raw)
In-Reply-To: <20241219225253.782792-1-stephen@networkplumber.org>
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
next prev parent reply other threads:[~2024-12-19 22:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Stephen Hemminger [this message]
2024-12-19 22:49 ` [PATCH v2 5/5] vhost: use strlcpy instead of strncpy Stephen Hemminger
2024-12-20 13:37 ` Bruce Richardson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241219225253.782792-5-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=dsinghrawat@marvell.com \
--cc=palok@marvell.com \
--cc=shahed.shaikh@cavium.com \
--cc=shshaikh@marvell.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).