aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2026-03-16 20:36:56 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2026-03-16 20:36:56 +0000
commitaa15df4597053c0e95a15b2a7036296999cd562a (patch)
tree3b3f65d87c8bcfb39429890de942986e09fdf616
parent889d10d5b12050b4b3923917b5edeac85e8ca706 (diff)
queue.h: Reorder STAILQ_INSERT_TAIL
The current implementation briefly violates the tail invariant. This is not usually an issue, but if an insert is in flight when a panic occurs, we may then trip the invariant while dumping core. MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: NetApp, Inc. Reviewed by: obiwac, olce, jhb Differential Revision: https://reviews.freebsd.org/D55819
-rw-r--r--sys/sys/queue.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/sys/queue.h b/sys/sys/queue.h
index aa6453889e6b..e2603bc664c3 100644
--- a/sys/sys/queue.h
+++ b/sys/sys/queue.h
@@ -499,9 +499,10 @@ struct { \
#define STAILQ_INSERT_TAIL(head, elm, field) do { \
QMD_STAILQ_CHECK_TAIL(head); \
+ __typeof__((head)->stqh_last) prevlast = (head)->stqh_last; \
STAILQ_NEXT((elm), field) = NULL; \
- *(head)->stqh_last = (elm); \
(head)->stqh_last = &STAILQ_NEXT((elm), field); \
+ *prevlast = (elm); \
} while (0)
#define STAILQ_LAST(head, type, field) \