Skip to content

Commit 9a308a8

Browse files
nhormanSashan
authored andcommitted
Orphan packets from qrx
It may occur that the qrx we allocate in port_default_packet handler to do AEAD validation isn't the one the channel ultimately uses (like if we turn off address validation). In that event, we need to ensure that anything we have on that qrx isn't returned to its free list to avoid early freeing when we free the qrx at the end of port_default_packet_handler, while those frames are still pending on the channel qrx Reviewed-by: Tim Hudson <[email protected]> Reviewed-by: Saša Nedvědický <[email protected]> (Merged from openssl#27004)
1 parent 0cfbeba commit 9a308a8

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

include/internal/quic_record_rx.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ int ossl_qrx_read_pkt(OSSL_QRX *qrx, OSSL_QRX_PKT **pkt);
259259
*/
260260
void ossl_qrx_pkt_release(OSSL_QRX_PKT *pkt);
261261

262+
/*
263+
* Like ossl_qrx_pkt_release, but just ensures that the refcount is dropped
264+
* on this qrx_pkt, and ensure its not on any list
265+
*/
266+
void ossl_qrx_pkt_orphan(OSSL_QRX_PKT *pkt);
267+
262268
/* Increments the reference count for the given packet. */
263269
void ossl_qrx_pkt_up_ref(OSSL_QRX_PKT *pkt);
264270

ssl/quic/quic_record_rx.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ void ossl_qrx_inject_pkt(OSSL_QRX *qrx, OSSL_QRX_PKT *pkt)
279279
* port_default_packet_handler() uses ossl_qrx_read_pkt()
280280
* to get pkt. Such packet has refcount 1.
281281
*/
282-
ossl_qrx_pkt_release(pkt);
282+
ossl_qrx_pkt_orphan(pkt);
283283
if (ossl_assert(rxe->refcount == 0))
284284
ossl_list_rxe_insert_tail(&qrx->rx_pending, rxe);
285285
}
@@ -1473,6 +1473,19 @@ void ossl_qrx_pkt_release(OSSL_QRX_PKT *pkt)
14731473
qrx_recycle_rxe(pkt->qrx, rxe);
14741474
}
14751475

1476+
void ossl_qrx_pkt_orphan(OSSL_QRX_PKT *pkt)
1477+
{
1478+
RXE *rxe;
1479+
1480+
if (pkt == NULL)
1481+
return;
1482+
rxe = (RXE *)pkt;
1483+
assert(rxe->refcount > 0);
1484+
rxe->refcount--;
1485+
assert(ossl_list_rxe_prev(rxe) == NULL && ossl_list_rxe_next(rxe) == NULL);
1486+
return;
1487+
}
1488+
14761489
void ossl_qrx_pkt_up_ref(OSSL_QRX_PKT *pkt)
14771490
{
14781491
RXE *rxe = (RXE *)pkt;

0 commit comments

Comments
 (0)