Skip to content

Commit 1160b80

Browse files
authored
More silo enlightenment (#5220)
Attach to the right silo when uninitializing a connection. Otherwise, the security context could be freed in a silo that's not where the context was allocated.
1 parent 5356efa commit 1160b80

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/core/connection.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ QuicConnFree(
309309
)
310310
{
311311
QUIC_PARTITION* Partition = Connection->Partition;
312+
#ifdef QUIC_SILO
313+
QUIC_SILO Silo = NULL;
314+
QuicConfigurationAttachSilo(Connection->Configuration);
315+
#endif
316+
312317
CXPLAT_FRE_ASSERT(!Connection->State.Freed);
313318
CXPLAT_TEL_ASSERT(Connection->RefCount == 0);
314319
if (Connection->State.ExternalOwner) {
@@ -369,6 +374,15 @@ QuicConnFree(
369374
QuicDatagramSendShutdown(&Connection->Datagram);
370375
QuicDatagramUninitialize(&Connection->Datagram);
371376
if (Connection->Configuration != NULL) {
377+
#ifdef QUIC_SILO
378+
//
379+
// Take a ref on the silo before releasing the configuration
380+
// to prevent the silo from being destroyed while we are still
381+
// holding onto the thread to clean up other stuff for this connection.
382+
//
383+
Silo = Connection->Configuration->Silo;
384+
QuicSiloAddRef(Silo);
385+
#endif
372386
QuicConfigurationRelease(Connection->Configuration);
373387
Connection->Configuration = NULL;
374388
}
@@ -408,6 +422,10 @@ QuicConnFree(
408422
InterlockedDecrement(&MsQuicLib.ConnectionCount);
409423
#endif
410424
QuicPerfCounterDecrement(Partition, QUIC_PERF_COUNTER_CONN_ACTIVE);
425+
#ifdef QUIC_SILO
426+
QuicConfigurationDetachSilo();
427+
QuicSiloRelease(Silo);
428+
#endif
411429
}
412430

413431
_IRQL_requires_max_(PASSIVE_LEVEL)

0 commit comments

Comments
 (0)