patch 'eal/freebsd: unregister alarm callback before free' has been queued to stable release 22.11.9

luca.boccassi at gmail.com luca.boccassi at gmail.com
Thu Jun 12 23:07:21 CEST 2025


Hi,

FYI, your patch has been queued to stable release 22.11.9

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 06/14/25. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/8254c4d5c935e94ecc8f574d545319653d623d49

Thanks.

Luca Boccassi

---
>From 8254c4d5c935e94ecc8f574d545319653d623d49 Mon Sep 17 00:00:00 2001
From: Rui Ferreira <rui.ferreira1 at h-partners.com>
Date: Fri, 30 May 2025 09:18:44 +0100
Subject: [PATCH] eal/freebsd: unregister alarm callback before free

[ upstream commit cf1937a96dcf63f6e00e3181654a845edb1fd682 ]

Unregister callback on cleanup to avoid use after free from the
interrupt thread (eal_intr_thread_main).

To be more defensive, set ptr to NULL if we can unregister.

rte_intr_callback_unregister_sync may (optionally) use traces
so the alarm cleanup must happen before eal_trace_fini to avoid
accessing freed memory.

Bugzilla ID: 1683
Fixes: 90b13ab8d4f7 ("alarm: remove direct access to interrupt handle")

Signed-off-by: Rui Ferreira <rui.ferreira1 at h-partners.com>
Acked-by: Bruce Richardson <bruce.richardson at intel.com>
Signed-off-by: Thomas Monjalon <thomas at monjalon.net>
---
 lib/eal/freebsd/eal.c       | 2 +-
 lib/eal/freebsd/eal_alarm.c | 8 +++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/eal/freebsd/eal.c b/lib/eal/freebsd/eal.c
index 122daf6c1f..008a6c68e4 100644
--- a/lib/eal/freebsd/eal.c
+++ b/lib/eal/freebsd/eal.c
@@ -904,9 +904,9 @@ rte_eal_cleanup(void)
 	rte_service_finalize();
 	rte_mp_channel_cleanup();
 	eal_bus_cleanup();
+	rte_eal_alarm_cleanup();
 	rte_trace_save();
 	eal_trace_fini();
-	rte_eal_alarm_cleanup();
 	/* after this point, any DPDK pointers will become dangling */
 	rte_eal_memory_detach();
 	eal_cleanup_config(internal_conf);
diff --git a/lib/eal/freebsd/eal_alarm.c b/lib/eal/freebsd/eal_alarm.c
index 1a3e6c0aad..d598f6aaf5 100644
--- a/lib/eal/freebsd/eal_alarm.c
+++ b/lib/eal/freebsd/eal_alarm.c
@@ -48,7 +48,13 @@ static void eal_alarm_callback(void *arg);
 void
 rte_eal_alarm_cleanup(void)
 {
-	rte_intr_instance_free(intr_handle);
+	/* unregister callback using intr_handle in interrupt thread */
+	int ret = rte_intr_callback_unregister_sync(intr_handle,
+			eal_alarm_callback, (void *)-1);
+	if (ret >= 0) {
+		rte_intr_instance_free(intr_handle);
+		intr_handle = NULL;
+	}
 }
 
 int
-- 
2.47.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2025-06-12 22:06:26.189443151 +0100
+++ 0064-eal-freebsd-unregister-alarm-callback-before-free.patch	2025-06-12 22:06:23.894045145 +0100
@@ -1 +1 @@
-From cf1937a96dcf63f6e00e3181654a845edb1fd682 Mon Sep 17 00:00:00 2001
+From 8254c4d5c935e94ecc8f574d545319653d623d49 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit cf1937a96dcf63f6e00e3181654a845edb1fd682 ]
+
@@ -17 +18,0 @@
-Cc: stable at dpdk.org
@@ -28 +29 @@
-index d6fffa2170..45adfad668 100644
+index 122daf6c1f..008a6c68e4 100644
@@ -31 +32 @@
-@@ -906,9 +906,9 @@ rte_eal_cleanup(void)
+@@ -904,9 +904,9 @@ rte_eal_cleanup(void)
@@ -43 +44 @@
-index 28f285fdef..c03e281e67 100644
+index 1a3e6c0aad..d598f6aaf5 100644
@@ -46 +47 @@
-@@ -50,7 +50,13 @@ static void eal_alarm_callback(void *arg);
+@@ -48,7 +48,13 @@ static void eal_alarm_callback(void *arg);


More information about the stable mailing list