File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed
java/org/apache/tomcat/util/net/openssl Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 3030import java .util .List ;
3131import java .util .Map ;
3232import java .util .Set ;
33+ import java .util .concurrent .locks .Lock ;
3334
3435import javax .net .ssl .SSLEngine ;
3536import javax .net .ssl .SSLEngineResult ;
4243
4344import org .apache .juli .logging .Log ;
4445import org .apache .juli .logging .LogFactory ;
46+ import org .apache .tomcat .jni .AprStatus ;
4547import org .apache .tomcat .jni .Buffer ;
4648import org .apache .tomcat .jni .Pool ;
4749import org .apache .tomcat .jni .SSL ;
@@ -222,9 +224,9 @@ public String getNegotiatedProtocol() {
222224 public synchronized void shutdown () {
223225 if (!destroyed ) {
224226 destroyed = true ;
225- cleanable .clean ();
226227 // internal errors can cause shutdown without marking the engine closed
227228 isInboundDone = isOutboundDone = engineClosed = true ;
229+ cleanable .clean ();
228230 ByteBufferUtils .cleanDirectBuffer (buf );
229231 }
230232 }
@@ -1400,11 +1402,19 @@ public int getApplicationBufferSize() {
14001402 private record OpenSSLState (long ssl , long networkBIO ) implements Runnable {
14011403 @ Override
14021404 public void run () {
1403- if (networkBIO != 0 ) {
1404- SSL .freeBIO (networkBIO );
1405- }
1406- if (ssl != 0 ) {
1407- SSL .freeSSL (ssl );
1405+ Lock readLock = AprStatus .getStatusLock ().readLock ();
1406+ readLock .lock ();
1407+ try {
1408+ if (!AprStatus .isAprInitialized ()) {
1409+ if (networkBIO != 0 ) {
1410+ SSL .freeBIO (networkBIO );
1411+ }
1412+ if (ssl != 0 ) {
1413+ SSL .freeSSL (ssl );
1414+ }
1415+ }
1416+ } finally {
1417+ readLock .unlock ();
14081418 }
14091419 }
14101420 }
Original file line number Diff line number Diff line change 307307 Fix OpenSSL FFM code compatibility with LibreSSL versions below 3.5.
308308 (remm)
309309 </fix >
310+ <fix >
311+ Prevent concurrent release of <code >OpenSSLEngine</code > resources and
312+ the termination of the Tomcat Native library as it might cause crashes
313+ during Tomcat shutdown. (markt)
314+ </fix >
310315 </changelog >
311316 </subsection >
312317 <subsection name =" Jasper" >
You can’t perform that action at this time.
0 commit comments