net: tcp: account for SYN-ACK payload sequence numbers
PATCH 1/1 net: tcp: account for SYN-ACK payload sequence numbers
A SYN consumes one sequence number. Passing a SYN-ACK's sequence number to tcp_rx_user_data() for its payload underflows the receive offset to 0xffffffff. On 64-bit systems, wget can then write the payload almost 4 GiB past its requested destination.
Start SYN-ACK payloads at the first data sequence and drop data before that sequence. Validate the TCP header length before deriving the payload length. For wget callers that set buffer_size, compare offset and length without overflowing their sum. The normal wget command relies on the TCP sequence correction since its buffer_size is zero.
---
Tested on qemu_arm64 with CONFIG_CMD_WGET and on sandbox. A SYN-ACK with payload is now stored at the wget load address instead of wrapping nearly 4 GiB past it. A follow-up HTTP wget of a 622-byte file completed, and the bytes read back matched the file. The previous wrap-write sandbox check no longer observes a store at loadaddr+0xffffffff.
net/tcp.c | 9 ++++++++- net/wget.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
net/tcp.c +8 -1
@@ -936,6 +936,10 @@ static int tcp_rx_user_data(struct tcp_stream *tcp, u32 tcp_seq_num,return TCP_PACKET_DROP ; } +/* A byte before the initial data sequence cannot have a valid offset. */ +if (tcp_seq_cmp (tcp_seq_num, tcp->irs +1 ) <0 ) +return TCP_PACKET_DROP ; + tmp_len = len; old_offs =tcp_stream_rx_offs (tcp); buf_offs = tcp_seq_num - tcp->irs -1 ;
@@ -973,6 +977,8 @@ void tcp_rx_state_machine(struct tcp_stream *tcp,u8 tcp_flags, action; tcp_hdr_len =GET_TCP_HDR_LEN_IN_BYTES (b->ip.hdr.tcp_hlen); +if (tcp_hdr_len <TCP_HDR_SIZE || tcp_hdr_len > tcp_len) +return ; payload_len = tcp_len - tcp_hdr_len;if (tcp_hdr_len >TCP_HDR_SIZE )
@@ -1058,7 +1064,8 @@ void tcp_rx_state_machine(struct tcp_stream *tcp, action =tcp_stream_fin_needed (tcp, tcp->snd_una) |TCP_ACK ;tcp_send_packet (tcp, action, tcp->snd_una, tcp->rcv_nxt,0 ); -tcp_rx_user_data (tcp, tcp_seq_num, +/* SYN consumes one sequence number before its payload. */ +tcp_rx_user_data (tcp, tcp_seq_num +1 , ((char *)b) + pkt_len - payload_len, payload_len);return ;
net/wget.c +4 -2
@@ -50,8 +50,10 @@ static inline int store_block(uchar *src, unsigned int offset, unsigned int len)ulong store_addr = image_load_addr + offset;uchar *ptr; -// Avoid overflow -if (wget_info->buffer_size && wget_info->buffer_size < offset + len) +/* Compare without wrapping the 32-bit offset and length. */ +if (wget_info->buffer_size && + (offset > wget_info->buffer_size || + len > wget_info->buffer_size - offset))return -1 ;if (CONFIG_IS_ENABLED (LMB ) && wget_info->set_bootdev) { if (store_addr < image_load_addr ||
Signature · 1 line
2.43.0
Hello,
This is a short note on the security issue behind the patch we sent on 2 Nov 2026 (Message-ID:
<[email protected]>).
In TCP_SYN_SENT, a SYN-ACK with a payload is delivered to tcp_rx_user_data() using the SYN sequence number after irs has already been set from that same segment. buf_offs = seq - irs - 1 then underflows to 0xffffffff, and wget store_block() writes the payload at image_load_addr + 0xffffffff. The header is legal; payload_len is positive.
That is a controlled out-of-bounds write. We score the proven impact as CVSS 3.1 AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:L = 8.2. We are not claiming confidentiality impact or a shipping-product RCE; those would need a consumed boot asset at the wrap address, which we have not shown on a vendor image.
This is a missing sibling of CVE-2026-29008, not an incomplete fix of it. 29008 is a negative payload_len from a bogus data-offset. This path uses a valid header and a sequence-accounting error. A fix that only rejects payload_len < 0 would not close it. We have not found a merged 29008 patch in mainline.
Affected: CONFIG_PROT_TCP / CONFIG_WGET, introduced in bf962de97c37 ("net/tcp: improve tcp framework, use better state machine"). The posted patch accounts SYN-ACK data at seq+1, drops pre-IRS data, bounds the TCP header length (which also stops the 29008-style negative length), and makes the wget buffer_size check wrap-safe when buffer_size is set.
We are not attaching a PoC. Happy to answer review comments on the patch. If a CVE is wanted, U-Boot does not assign them; we can request one separately and add the id to the commit if you prefer.
Thanks,
Shubham Antil
Octane Security
Quoted 25 lines
A SYN consumes one sequence number. Passing a SYN-ACK's sequence number to
tcp_rx_user_data()for its payload underflows the receive offset to0xffffffff. On 64-bit systems, wget can then write the payload almost 4 GiB past its requested destination.Start SYN-ACK payloads at the first data sequence and drop data before that sequence. Validate the TCP header length before deriving the payload length. For wget callers that set
buffer_size, compare offset and length without overflowing their sum. The normal wget command relies on the TCP sequence correction since itsbuffer_sizeis zero.Fixes bf962de97c37 ("net/tcp: improve tcp framework, use better state machine")Signed-off-by Shubham Antil <[email protected]>Cc Jerome Forissier <[email protected]>Cc Tom Rini <[email protected]>Cc Mikhail Kshevetskiy <[email protected]>---
Tested onqemu_arm64withCONFIG_CMD_WGETand on sandbox. A SYN-ACK with payload is now stored at the wget load address instead of wrapping nearly 4 GiB past it. A follow-up HTTP wget of a 622-byte file completed, and the bytes read back matched the file. The previous wrap-write sandbox check no longer observes a store atloadaddr+0xffffffff.
Quoted 3 lines
net/tcp.c | 9 ++++++++- net/wget.c | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-)
Applied to u-boot-net branch for-main [1], thanks!
[1] https://git.u-boot-project.org/u-boot/custodians/u-boot-net/-/commits/for-main
[1/1] net: tcp: account for SYN-ACK payload sequence numbers
commit: ebda987c6ecfe1cd609ce37e036c2938bc3c98e9
Best regards,
Signature · 1 line
Jerome Forissier <[email protected]>