Skip to content

Commit 8693c2c

Browse files
committed
BUG/MINOR: quic: too short PADDING frame for too short packets
This bug arrvived with this commit: MINOR: quic: centralize padding for HP sampling on packet building What was missed is the fact that at the centralization point for the PADDING frame to add for too short packet, <len> payload length already includes <*pn_len> the packet number field length value. So when computing the length of the PADDING frame, the packet field length must not be considered and added to the payload length (<len>). This bug leaded too short PADDING frame to too short packets. This was the case, most of times with Application level packets with a 1-byte packet number field followed by a 1-byte PING frame. A 1-byte PADDING frame was added in this case in place of a correct 2-bytes PADDINF frame. The header packet protection of such packet could not be removed by the clients as for instance for ngtcp2 with such traces: I00001828 0x5a135c81e803f092c74bac64a85513b657 pkt could not decrypt packet number No need to backport.
1 parent e6c791b commit 8693c2c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

include/haproxy/quic_conn-t.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ enum quic_pkt_type {
145145
#define QUIC_PACKET_PNL_BITMASK 0x03
146146
#define QUIC_PACKET_PN_MAXLEN 4
147147

148-
/* TLS algo supported by QUIC uses a 16-bytes sample for HP. */
149-
#define QUIC_HP_SAMPLE_LEN 16
150-
151148
/*
152149
* 0 1 2 3
153150
* 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

src/quic_tx.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,12 +1990,16 @@ static int qc_do_build_pkt(unsigned char *pos, const unsigned char *end,
19901990
*/
19911991

19921992
/* Add padding if packet is too small for HP sampling as specified
1993-
* above. QUIC TLS algos relies on 16 bytes sample extracted 4 bytes
1994-
* after PN offset. Thus, pn and payload must be at least 4 bytes long,
1995-
* so that the sample will be extracted as the AEAD tag.
1993+
* above. QUIC TLS algos relies on 16 bytes sample extracted
1994+
* QUIC_PACKET_PN_MAXLEN(4) bytes after the PN offset Thus, pn and payload
1995+
* must be at least QUIC_PACKET_PN_MAXLEN(4) bytes long, so that the sample
1996+
* will be extracted as the AEAD tag.
1997+
*
1998+
* Note that from here, <len> includes <*pn_len>, the total frame lenghts,
1999+
* and QUIC_TLS_TAG_LEN(16).
19962000
*/
1997-
if (*pn_len + len < QUIC_PACKET_PN_MAXLEN + QUIC_HP_SAMPLE_LEN) {
1998-
padding_len = QUIC_PACKET_PN_MAXLEN + QUIC_HP_SAMPLE_LEN - (*pn_len + len);
2001+
if (len < QUIC_PACKET_PN_MAXLEN + QUIC_TLS_TAG_LEN) {
2002+
padding_len = QUIC_PACKET_PN_MAXLEN + QUIC_TLS_TAG_LEN - len;
19992003
TRACE_PRINTF(TRACE_LEVEL_DEVELOPER, QUIC_EV_CONN_PHPKTS, qc, 0, 0, 0,
20002004
"adding padding pn=%llu padding_len=%zu *pn_len=%zu"
20012005
" len=%zu len_frms=%zu",

0 commit comments

Comments
 (0)