git: 3cf9ba059b80 - stable/15 - libalias: Serialize updates to the global instance list
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 Jun 2026 18:01:52 UTC
The branch stable/15 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=3cf9ba059b80711049f8290333b0fc61e61798b2
commit 3cf9ba059b80711049f8290333b0fc61e61798b2
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2026-06-08 22:46:32 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-06-15 16:00:04 +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 c143d74a2f45..0861743a68dd 100644
--- a/sys/netinet/libalias/alias_db.c
+++ b/sys/netinet/libalias/alias_db.c
@@ -33,6 +33,7 @@
#include <sys/systm.h>
#include <sys/lock.h>
#include <sys/module.h>
+#include <sys/mutex.h>
#include <sys/rwlock.h>
#include <sys/stdarg.h>
#include <sys/syslog.h>
@@ -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;
@@ -2190,8 +2195,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;
@@ -2259,8 +2270,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);