From: sashiko-bot@kernel.org
To: "Xuanqiang Luo" <xuanqiang.luo@linux.dev>
Cc: bpf@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH net-next v1 5/6] tcp: avoid a stack canary in tcp_rcv_established()
Date: Wed, 25 Nov 2026 13:09:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-233462@kernel.org> (raw)
In-Reply-To: <20261124130631.1886963-6-xuanqiang.luo@linux.dev>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] tcp: post-FIN segments queued in tcp_rcv_state_process() and
tcp_data_queue() [1]
--
commit a4b62910075d79274253c31ee8181da76c593e87
Author: Xuanqiang Luo <luoxuanqiang@kylinos.cn>
tcp: avoid a stack canary in tcp_rcv_established()
This commit changes tcp_try_coalesce(), tcp_ooo_try_coalesce() and
tcp_queue_rcv() to return an enum tcp_eaten by value instead of taking a
boolean pointer for fragstolen, avoiding a stack canary in
tcp_rcv_established() and tcp_data_queue().
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 801c76744ed8a..3d0a8b7e883e4 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
[ ... ]
> @@ -5756,7 +5761,7 @@ static void tcp_data_queue(struct sock *sk, struct sk_buff *skb)
> sk_forced_mem_schedule(sk, skb->truesize);
> }
>
> - eaten = tcp_queue_rcv(sk, skb, &fragstolen);
> + eaten = tcp_queue_rcv(sk, skb);
> if (skb->len)
> tcp_event_data_recv(sk, skb);
> if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_FIN)
[Severity: High]
This problem wasn't introduced by this patch, but can a peer queue
post-FIN payload onto sk->sk_receive_queue and advance tp->rcv_nxt after
EOF [1]?
After an in-order FIN has been processed, RCV_SHUTDOWN is set and
tp->rcv_nxt has advanced past the FIN sequence number. If a socket in
TCP_CLOSE_WAIT, TCP_CLOSING, or TCP_LAST_ACK with a non-zero receive
window receives a segment with seq == tp->rcv_nxt - 1, 1 byte of payload,
and TCPHDR_FIN set (end_seq == tp->rcv_nxt + 1), both checks in
tcp_rcv_state_process() are bypassed:
net/ipv4/tcp_input.c:tcp_rcv_state_process() {
...
case TCP_CLOSE_WAIT:
case TCP_CLOSING:
case TCP_LAST_ACK:
if (!before(TCP_SKB_CB(skb)->seq, tp->rcv_nxt)) {
...
break;
}
fallthrough;
case TCP_FIN_WAIT1:
case TCP_FIN_WAIT2:
if (sk->sk_shutdown & RCV_SHUTDOWN) {
if (TCP_SKB_CB(skb)->end_seq != TCP_SKB_CB(skb)->seq &&
after(TCP_SKB_CB(skb)->end_seq - th->fin, tp->rcv_nxt)) {
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONDATA);
tcp_reset(sk, skb);
return SKB_DROP_REASON_TCP_ABORT_ON_DATA;
}
}
fallthrough;
case TCP_ESTABLISHED:
tcp_data_queue(sk, skb);
...
}
Subtracting th->fin from end_seq yields tp->rcv_nxt, so the RCV_SHUTDOWN
check does not reset the connection and calls tcp_data_queue(). Because
seq < tp->rcv_nxt < end_seq, tcp_data_queue() treats the packet as a
partial overlap and jumps to queue_and_out, where tcp_queue_rcv() queues
the post-FIN data and advances tp->rcv_nxt.
This corrupts tcp_inq() unread byte accounting after EOF and
desynchronizes tp->copied_seq from kTLS record consumption in
tcp_read_done(), which stops at the first skb carrying TCPHDR_FIN while
tls_strp_check_queue_ok() accepts multi-skb records across FIN boundaries.
[1] https://sashiko.dev/#/bug/linux-ddef83cf-eb5a-48d6-b4ef-687a557a5260
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261124130631.1886963-1-xuanqiang.luo@linux.dev?part=5
next prev parent reply other threads:[~2026-11-25 13:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 13:06 [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 1/6] tcp: avoid a stack canary in __tcp_select_window() Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 2/6] ipv4: avoid a stack canary in ip_finish_output2() Xuanqiang Luo
2026-11-25 13:09 ` sashiko-bot
2026-11-24 13:06 ` [PATCH net-next v1 3/6] ipv4: raw: do not use skb_header_pointer() in icmp_filter() Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 4/6] net: avoid stack canaries in skb_try_coalesce() callers Xuanqiang Luo
2026-11-24 13:06 ` [PATCH net-next v1 5/6] tcp: avoid a stack canary in tcp_rcv_established() Xuanqiang Luo
2026-11-25 13:09 ` sashiko-bot [this message]
2026-11-24 13:06 ` [PATCH net-next v1 6/6] tcp: do not call bpf_skops_write_hdr_opt() unless needed Xuanqiang Luo
2026-11-26 8:48 ` [PATCH net-next v1 0/6] net: avoid stack canaries in TCP/IPv4 fast paths gang.yan
2026-11-27 6:18 ` Xuanqiang Luo
2026-11-26 10:20 ` David Laight
2026-11-27 6:33 ` Xuanqiang Luo
2026-11-27 10:41 ` David Laight
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-233462@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xuanqiang.luo@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.