git: 4b539c58e986 - stable/14 - libalias: Serialize updates to the global instance list
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 14 Jul 2026 14:56:10 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=4b539c58e986ad46d2180abba33796511669124f
commit 4b539c58e986ad46d2180abba33796511669124f
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-06-08 22:46:32 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-07-14 13:02:07 +0000
libalias: Serialize updates to the global instance list
libalias maintains a global list of all libalias handles. The list was
updated without any locking, but nothing prevents updates from running
concurrently.
MFC after: 1 week
(cherry picked from commit 2ff705f32a2033201a8f83f1ade5ddbc0460387d)
---
sys/netinet/libalias/alias_db.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/sys/netinet/libalias/alias_db.c b/sys/netinet/libalias/alias_db.c
index 4bb95549aaaf..365e89138ce6 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -34,6 +34,7 @@
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/module.h>
+#include <sys/mutex.h>
#include <sys/rwlock.h>
#include <sys/syslog.h>
#else
@@ -61,6 +62,10 @@
#include "alias_db.h"
+#ifdef _KERNEL
+static struct mtx list_mtx;
+MTX_SYSINIT(libalias_list, &list_mtx, "libalias list lock", MTX_DEF);
+#endif
static LIST_HEAD(, libalias) instancehead = LIST_HEAD_INITIALIZER(instancehead);
int LibAliasTime;
@@ -2099,8 +2104,14 @@ LibAliasInit(struct libalias *la)
/* kernel cleans up on module unload */
if (LIST_EMPTY(&instancehead))
atexit(finishoff);
+#endif
+#ifdef _KERNEL
+ mtx_lock(&list_mtx);
#endif
LIST_INSERT_HEAD(&instancehead, la, instancelist);
+#ifdef _KERNEL
+ mtx_unlock(&list_mtx);
+#endif
#ifdef _KERNEL
LibAliasTime = time_uptime;
@@ -2167,8 +2178,14 @@ LibAliasUninit(struct libalias *la)
UninitPacketAliasLog(la);
#ifndef NO_FW_PUNCH
UninitPunchFW(la);
+#endif
+#ifdef _KERNEL
+ mtx_lock(&list_mtx);
#endif
LIST_REMOVE(la, instancelist);
+#ifdef _KERNEL
+ mtx_unlock(&list_mtx);
+#endif
LIBALIAS_UNLOCK(la);
LIBALIAS_LOCK_DESTROY(la);
free(la);