Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Mar 2026 20:37:03 +0000
From:      Dag-Erling=?utf-8?Q? Sm=C3=B8rg?=rav <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: aa15df459705 - main - queue.h: Reorder STAILQ_INSERT_TAIL
Message-ID:  <69b869ef.3fa86.bffed26@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=aa15df4597053c0e95a15b2a7036296999cd562a

commit aa15df4597053c0e95a15b2a7036296999cd562a
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-03-16 20:36:56 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-03-16 20:36:56 +0000

    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
---
 sys/sys/queue.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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)					\


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69b869ef.3fa86.bffed26>