git: b5c08433224b - stable/14 - cxgbe/t4_tom: Add synq entry to the list before calling send_synack.

From: Navdeep Parhar <np_at_FreeBSD.org>
Date: Mon, 21 Oct 2024 18:39:27 UTC
The branch stable/14 has been updated by np:

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

commit b5c08433224be47da8ce5d4ea66f17e58cfbf650
Author:     Navdeep Parhar <np@FreeBSD.org>
AuthorDate: 2024-09-06 06:21:59 +0000
Commit:     Navdeep Parhar <np@FreeBSD.org>
CommitDate: 2024-10-21 17:09:37 +0000

    cxgbe/t4_tom: Add synq entry to the list before calling send_synack.
    
    This fixes a panic where the peer's ack to the synack arrives on a
    different queue and do_pass_establish tries to remove the synqe from
    synqe_list before it has been added by do_pass_accept_req.
    
    Reported by:    Sony Arpita Das @ Chelsio
    Fixes:  283333c0e329 cxgbe/t4_tom: Track all synq entries in a per-adapter list.
    Sponsored by:   Chelsio Communications
    
    (cherry picked from commit 674cbf38f6d0a0b307e52c4265da9f077606b035)
---
 sys/dev/cxgbe/tom/t4_listen.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/sys/dev/cxgbe/tom/t4_listen.c b/sys/dev/cxgbe/tom/t4_listen.c
index f91d193c0fed..8a39218a55ba 100644
--- a/sys/dev/cxgbe/tom/t4_listen.c
+++ b/sys/dev/cxgbe/tom/t4_listen.c
@@ -1494,18 +1494,20 @@ found:
 		synqe->tid = tid;
 		synqe->syn = m;
 		m = NULL;
+		mtx_lock(&td->toep_list_lock);
+		TAILQ_INSERT_TAIL(&td->synqe_list, synqe, link);
+		mtx_unlock(&td->toep_list_lock);
 
 		if (send_synack(sc, synqe, opt0, opt2, tid) != 0) {
 			remove_tid(sc, tid, ntids);
 			m = synqe->syn;
 			synqe->syn = NULL;
+			mtx_lock(&td->toep_list_lock);
+			TAILQ_REMOVE(&td->synqe_list, synqe, link);
+			mtx_unlock(&td->toep_list_lock);
 			NET_EPOCH_EXIT(et);
 			REJECT_PASS_ACCEPT_REQ(true);
 		}
-
-		mtx_lock(&td->toep_list_lock);
-		TAILQ_INSERT_TAIL(&td->synqe_list, synqe, link);
-		mtx_unlock(&td->toep_list_lock);
 		CTR6(KTR_CXGBE,
 		    "%s: stid %u, tid %u, synqe %p, opt0 %#016lx, opt2 %#08x",
 		    __func__, stid, tid, synqe, be64toh(opt0), be32toh(opt2));