git: 2af08ab3f125 - main - netipsec: Release the sahtree lock on the AH and IPComp EAGAIN paths

From: R. Christian McDonald <rcm_at_FreeBSD.org>
Date: Wed, 11 Nov 2026 02:32:06 UTC
The branch main has been updated by rcm:

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

commit 2af08ab3f125ce5988a641c32c777afc52f917e1
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-11-11 02:31:22 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-11-11 02:31:22 +0000

    netipsec: Release the sahtree lock on the AH and IPComp EAGAIN paths
    
    183513d15f22 made the AH, ESP and IPComp input callbacks hold the
    sahtree read lock, but only esp_input_cb() drops it before resubmitting
    a request that the crypto framework completed with EAGAIN.
    ah_input_cb() and ipcomp_input_cb() return with the lock still held.
    
    crypto_invoke() completes requests with EAGAIN while their driver
    detaches.  Detaching ossl(4) under inbound AH traffic then hangs the
    next rmlock writer, and the system panics with "spin lock held too
    long" in smp_rendezvous_cpus() called from _rm_wlock().
    
    Release the lock as esp_input_cb() does.
    
    Reported by:            llm-postcr
    Reviewed by:            kib
    Fixes:                  183513d15f22 ("sys/netipsec: ensure sah stability during input callback processing")
    MFC after:              1 week
    Sponsored by:           Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D61399
---
 sys/netipsec/xform_ah.c     | 1 +
 sys/netipsec/xform_ipcomp.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sys/netipsec/xform_ah.c b/sys/netipsec/xform_ah.c
index 7b913bfcce08..cea329eaa827 100644
--- a/sys/netipsec/xform_ah.c
+++ b/sys/netipsec/xform_ah.c
@@ -729,6 +729,7 @@ ah_input_cb(struct cryptop *crp)
 			if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0)
 				crypto_freesession(cryptoid);
 			xd->cryptoid = crp->crp_session;
+			ipsec_sahtree_runlock(&sahtree_tracker);
 			CURVNET_RESTORE();
 			return (crypto_dispatch(crp));
 		}
diff --git a/sys/netipsec/xform_ipcomp.c b/sys/netipsec/xform_ipcomp.c
index f7d4f08ffae9..aecaf79f39bd 100644
--- a/sys/netipsec/xform_ipcomp.c
+++ b/sys/netipsec/xform_ipcomp.c
@@ -321,6 +321,7 @@ ipcomp_input_cb(struct cryptop *crp)
 			if (ipsec_updateid(sav, &crp->crp_session, &cryptoid) != 0)
 				crypto_freesession(cryptoid);
 			xd->cryptoid = crp->crp_session;
+			ipsec_sahtree_runlock(&sahtree_tracker);
 			CURVNET_RESTORE();
 			return (crypto_dispatch(crp));
 		}