FAILED: patch "[PATCH] tcp: challenge ACK for non-exact RST in SYN-RECEIVED" failed to apply to 6.12-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x a28c4fcbf774e23b4779cae468e3497a5ad1f4a1
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026072944-maritime-sulfide-d951@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From a28c4fcbf774e23b4779cae468e3497a5ad1f4a1 Mon Sep 17 00:00:00 2001
From: Yuxiang Yang <[email protected]>
Date: Fri, 17 Jul 2026 08:14:42 +0000
Subject: [PATCH] tcp: challenge ACK for non-exact RST in SYN-RECEIVED
The SYN-RECEIVED request-socket path in tcp_check_req() accepts an in-window RST without requiring SEG.SEQ to exactly match RCV.NXT. A non-exact RST therefore removes the request instead of eliciting a challenge ACK.
RFC 9293 section 3.10.7.4 applies the RFC 5961 reset check in
SYN-RECEIVED: an exact RST resets the connection, while a non-exact in-window RST must trigger a challenge ACK and be dropped.
Apply that check before the ACK-field validation, following the RFC sequence-number, RST, then ACK processing order. Factor the per-netns challenge ACK quota out of tcp_send_challenge_ack() so request sockets can share it. Use the request socket's send_ack() callback and its own out-of-window ACK timestamp to send and rate-limit the response.
include/net/tcp.h +2 -0
@@ -1974,6 +1974,8 @@ static inline void tcp_fast_path_check(struct sock *sk)bool tcp_oow_rate_limited (struct net *net,const struct sk_buff *skb,int mib_idx,u32 *last_oow_ack_time); +void tcp_reqsk_send_challenge_ack (struct sock *sk,struct sk_buff *skb, +struct request_sock *req);static inline void tcp_mib_init (struct net *net) {
net/ipv4/tcp_input.c +43 -13
79 lines not on this page · raw message
net/ipv4/tcp_minisocks.c +11 -1
@@ -833,7 +833,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,* elsewhere and is checked directly against the child socket rather * than req because user data may have been sent out. */ -if ((flg &TCP_FLAG_ACK ) && !fastopen && +if ((flg &TCP_FLAG_ACK ) && !(flg &TCP_FLAG_RST ) && !fastopen && (TCP_SKB_CB (skb)->ack_seq !=tcp_rsk (req)->snt_isn +1 ))return sk;
@@ -872,6 +872,16 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, flg &= ~TCP_FLAG_SYN ; } +/* RFC 5961 section 3.2, as clarified by RFC 9293 section +* 3.10.7.4, requires a challenge ACK for a non-exact +* in-window RST in SYN-RECEIVED. +*/ +if ((flg &TCP_FLAG_RST ) && +TCP_SKB_CB (skb)->seq !=tcp_rsk (req)->rcv_nxt) { +tcp_reqsk_send_challenge_ack (sk, skb, req); +return NULL ; + } +/* RFC793: "second check the RST bit" and * "fourth, check the SYN bit" */
Sasha Levin
maintainerPATCH 1/4 tcp: Pass flags to __tcp_send_ack
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 9866884ce8ef25338c5b33cbb97c2b5d92088528 ]
Accurate ECN needs to send custom flags to handle IP-ECN field reflection during handshake.
Stable-dep-of: a28c4fcbf774 ("tcp: challenge ACK for non-exact RST in SYN-RECEIVED")
--- include/net/tcp.h | 2 +- net/ipv4/bpf_tcp_ca.c | 2 +- net/ipv4/tcp_dctcp.h | 2 +- net/ipv4/tcp_output.c | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-)
include/net/tcp.h +1 -1
@@ -668,7 +668,7 @@ void tcp_send_active_reset(struct sock *sk, gfp_t priority, enum sk_rst_reason reason);int tcp_send_synack (struct sock *);void tcp_push_one (struct sock *,unsigned int mss_now); -void __tcp_send_ack (struct sock *sk,u32 rcv_nxt); +void __tcp_send_ack (struct sock *sk,u32 rcv_nxt,u16 flags);void tcp_send_ack (struct sock *sk);void tcp_send_delayed_ack (struct sock *sk);void tcp_send_loss_probe (struct sock *sk);
net/ipv4/bpf_tcp_ca.c +1 -1
@@ -121,7 +121,7 @@ static int bpf_tcp_ca_btf_struct_access(struct bpf_verifier_log *log, BPF_CALL_2(bpf_tcp_send_ack, struct tcp_sock *, tp, u32, rcv_nxt) {/* bpf_tcp_ca prog cannot have NULL tp */ -__tcp_send_ack ((struct sock *)tp, rcv_nxt); +__tcp_send_ack ((struct sock *)tp, rcv_nxt,0 );return 0 ; }
net/ipv4/tcp_dctcp.h +1 -1
@@ -28,7 +28,7 @@ static inline void dctcp_ece_ack_update(struct sock *sk, enum tcp_ca_event evt,*/ if (inet_csk (sk)->icsk_ack.pending &ICSK_ACK_TIMER ) {dctcp_ece_ack_cwr (sk, *ce_state); -__tcp_send_ack (sk, *prior_rcv_nxt); +__tcp_send_ack (sk, *prior_rcv_nxt,0 ); }inet_csk (sk)->icsk_ack.pending |=ICSK_ACK_NOW ; }
net/ipv4/tcp_output.c +3 -3
@@ -4250,7 +4250,7 @@ void tcp_send_delayed_ack(struct sock *sk) }/* This routine sends an ack and also updates the window. */ -void __tcp_send_ack (struct sock *sk,u32 rcv_nxt) +void __tcp_send_ack (struct sock *sk,u32 rcv_nxt,u16 flags) {struct sk_buff *buff;
@@ -4279,7 +4279,7 @@ void __tcp_send_ack(struct sock *sk, u32 rcv_nxt)/* Reserve space for headers and prepare control bits. */ skb_reserve (buff,MAX_TCP_HEADER ); -tcp_init_nondata_skb (buff,tcp_acceptable_seq (sk),TCPHDR_ACK ); +tcp_init_nondata_skb (buff,tcp_acceptable_seq (sk),TCPHDR_ACK | flags);/* We do not want pure acks influencing TCP Small Queues or fq/pacing * too much.
@@ -4294,7 +4294,7 @@ EXPORT_SYMBOL_GPL(__tcp_send_ack);void tcp_send_ack (struct sock *sk) { -__tcp_send_ack (sk,tcp_sk (sk)->rcv_nxt); +__tcp_send_ack (sk,tcp_sk (sk)->rcv_nxt,0 ); }/* This routine sends a packet with an out of date sequence
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 tcp: fast path functions later
From: Ilpo Järvinen <[email protected]>
[ Upstream commit 61b2f7baa9779b12a7bf1b9800a3f2a2549a1315 ]
The following patch will use tcp_ecn_mode_accecn(), TCP_ACCECN_CEP_INIT_OFFSET, TCP_ACCECN_CEP_ACE_MASK in __tcp_fast_path_on() to make new flag for AccECN.
No functional changes.
Stable-dep-of: a28c4fcbf774 ("tcp: challenge ACK for non-exact RST in SYN-RECEIVED")
--- include/net/tcp.h | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-)
include/net/tcp.h +27 -27
@@ -768,33 +768,6 @@ static inline u32 __tcp_set_rto(const struct tcp_sock *tp)return usecs_to_jiffies ((tp->srtt_us >>3 ) + tp->rttvar_us); } -static inline void __tcp_fast_path_on (struct tcp_sock *tp,u32 snd_wnd) -{ -/* mptcp hooks are only on the slow path */ -if (sk_is_mptcp ((struct sock *)tp)) -return ; - - tp->pred_flags =htonl ((tp->tcp_header_len <<26 ) | -ntohl (TCP_FLAG_ACK ) | - snd_wnd); -} - -static inline void tcp_fast_path_on (struct tcp_sock *tp) -{ -__tcp_fast_path_on (tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); -} - -static inline void tcp_fast_path_check (struct sock *sk) -{ -struct tcp_sock *tp =tcp_sk (sk); - -if (RB_EMPTY_ROOT (&tp->out_of_order_queue) && - tp->rcv_wnd && -atomic_read (&sk->sk_rmem_alloc) < sk->sk_rcvbuf && - !tp->urg_data) -tcp_fast_path_on (tp); -} -u32 tcp_delack_max (const struct sock *sk);/* Compute the actual rto_min value */
@@ -1743,6 +1716,33 @@ static inline bool tcp_paws_reject(const struct tcp_options_received *rx_opt,return true; } +static inline void __tcp_fast_path_on (struct tcp_sock *tp,u32 snd_wnd) +{ +/* mptcp hooks are only on the slow path */ +if (sk_is_mptcp ((struct sock *)tp)) +return ; + + tp->pred_flags =htonl ((tp->tcp_header_len <<26 ) | +ntohl (TCP_FLAG_ACK ) | + snd_wnd); +} + +static inline void tcp_fast_path_on (struct tcp_sock *tp) +{ +__tcp_fast_path_on (tp, tp->snd_wnd >> tp->rx_opt.snd_wscale); +} + +static inline void tcp_fast_path_check (struct sock *sk) +{ +struct tcp_sock *tp =tcp_sk (sk); + +if (RB_EMPTY_ROOT (&tp->out_of_order_queue) && + tp->rcv_wnd && +atomic_read (&sk->sk_rmem_alloc) < sk->sk_rcvbuf && + !tp->urg_data) +tcp_fast_path_on (tp); +} +bool tcp_oow_rate_limited (struct net *net,const struct sk_buff *skb,int mib_idx,u32 *last_oow_ack_time);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 tcp: reorganize tcp_sock_write_txrx group for variables later
In reply to Sasha LevinFrom: Chia-Yu Chang <[email protected]>
[ Upstream commit c3426ba2ed6942fe33c75bf17fc7513ba2c6ac64 ]
Use the first 3-byte hole at the beginning of the tcp_sock_write_txrx group for 'noneagle'/'rate_app_limited' to fill in the existing hole in later patches. Therefore, the group size of tcp_sock_write_txrx is reduced from 92 + 4 to 91 + 4. In addition, the group size of tcp_sock_write_rx is changed to 96 to fit in the pahole outcome. Below are the trimmed pahole outcomes before and after this patch:
[BEFORE THIS PATCH]
struct tcp_sock {
[...]
__cacheline_group_begin__tcp_sock_write_txrx[0]; /* 2521 0 */
/* XXX 3 bytes hole, try to pack */
[...]
struct tcp_options_received rx_opt; /* 2588 24 */
u8 nonagle:4; /* 2612: 0 1 */
u8 rate_app_limited:1; /* 2612: 4 1 */
/* XXX 3 bits hole, try to pack */
__cacheline_group_end__tcp_sock_write_txrx[0]; /* 2613 0 */
/* XXX 3 bytes hole, try to pack */
__cacheline_group_begin__tcp_sock_write_rx[0] __attribute__((__aligned__(8))); /* 2616 0 */
[...]
__cacheline_group_end__tcp_sock_write_rx[0]; /* 2712 0 */
[...]
/* size: 3200, cachelines: 50, members: 161 */
}[AFTER THIS PATCH]
struct tcp_sock {
[...]
__cacheline_group_begin__tcp_sock_write_txrx[0]; /* 2521 0 */
u8 nonagle:4; /* 2521: 0 1 */
u8 rate_app_limited:1; /* 2521: 4 1 */
/* XXX 3 bits hole, try to pack */
/* XXX 2 bytes hole, try to pack */
[...]
struct tcp_options_received rx_opt; /* 2588 24 */
__cacheline_group_end__tcp_sock_write_txrx[0]; /* 2612 0 */
/* XXX 4 bytes hole, try to pack */
__cacheline_group_begin__tcp_sock_write_rx[0] __attribute__((__aligned__(8))); /* 2616 0 */
[...]
__cacheline_group_end__tcp_sock_write_rx[0]; /* 2712 0 */
[...]
/* size: 3200, cachelines: 50, members: 161 */
}Stable-dep-of: a28c4fcbf774 ("tcp: challenge ACK for non-exact RST in SYN-RECEIVED")
--- include/linux/tcp.h | 4 ++-- net/ipv4/tcp.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
include/linux/tcp.h +2 -2
@@ -282,6 +282,8 @@ struct tcp_sock {* Header prediction flags * 0x5?10 << 16 + snd_wnd in net byte order */ + u8 nonagle : 4,/* Disable Nagle algorithm? */ + rate_app_limited:1; /* rate_{delivered,interval_us} limited? */__be32 pred_flags;u64 tcp_clock_cache;/* cache last tcp_clock_ns() (see tcp_mstamp_refresh()) */ u64 tcp_mstamp;/* most recent packet received/sent */
@@ -300,8 +302,6 @@ struct tcp_sock {* Options received (usually on last packet, some only on SYN packets). */ struct tcp_options_received rx_opt; - u8 nonagle : 4,/* Disable Nagle algorithm? */ - rate_app_limited:1; /* rate_{delivered,interval_us} limited? */__cacheline_group_end (tcp_sock_write_txrx);/* RX read-write hotpath cache lines */
net/ipv4/tcp.c +2 -2
@@ -5061,7 +5061,7 @@ static void __init tcp_struct_check(void)/* 32bit arches with 8byte alignment on u64 fields might need padding * before tcp_clock_cache. */ - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 92 + 4); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_txrx, 91 + 4);/* RX read-write hotpath cache lines */ CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_received);
@@ -5078,7 +5078,7 @@ static void __init tcp_struct_check(void) CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, bytes_acked); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, rcv_rtt_est); CACHELINE_ASSERT_GROUP_MEMBER(struct tcp_sock, tcp_sock_write_rx, rcvq_space); - CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_rx, 99); + CACHELINE_ASSERT_GROUP_SIZE(struct tcp_sock, tcp_sock_write_rx, 96); }void __init tcp_init (void )
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 tcp: challenge ACK for non-exact RST in SYN-RECEIVED
In reply to Sasha LevinFrom: Yuxiang Yang <[email protected]>
[ Upstream commit a28c4fcbf774e23b4779cae468e3497a5ad1f4a1 ]
The SYN-RECEIVED request-socket path in tcp_check_req() accepts an in-window RST without requiring SEG.SEQ to exactly match RCV.NXT. A non-exact RST therefore removes the request instead of eliciting a challenge ACK.
RFC 9293 section 3.10.7.4 applies the RFC 5961 reset check in
SYN-RECEIVED: an exact RST resets the connection, while a non-exact in-window RST must trigger a challenge ACK and be dropped.
Apply that check before the ACK-field validation, following the RFC sequence-number, RST, then ACK processing order. Factor the per-netns challenge ACK quota out of tcp_send_challenge_ack() so request sockets can share it. Use the request socket's send_ack() callback and its own out-of-window ACK timestamp to send and rate-limit the response.
--- include/net/tcp.h | 2 ++ net/ipv4/tcp_input.c | 56 ++++++++++++++++++++++++++++++---------- net/ipv4/tcp_minisocks.c | 12 ++++++++- 3 files changed, 56 insertions(+), 14 deletions(-)
include/net/tcp.h +2 -0
@@ -1745,6 +1745,8 @@ static inline void tcp_fast_path_check(struct sock *sk)bool tcp_oow_rate_limited (struct net *net,const struct sk_buff *skb,int mib_idx,u32 *last_oow_ack_time); +void tcp_reqsk_send_challenge_ack (struct sock *sk,struct sk_buff *skb, +struct request_sock *req);static inline void tcp_mib_init (struct net *net) {
net/ipv4/tcp_input.c +43 -13
79 lines not on this page · raw message
net/ipv4/tcp_minisocks.c +11 -1
@@ -775,7 +775,7 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb,* elsewhere and is checked directly against the child socket rather * than req because user data may have been sent out. */ -if ((flg &TCP_FLAG_ACK ) && !fastopen && +if ((flg &TCP_FLAG_ACK ) && !(flg &TCP_FLAG_RST ) && !fastopen && (TCP_SKB_CB (skb)->ack_seq !=tcp_rsk (req)->snt_isn +1 ))return sk;
@@ -811,6 +811,16 @@ struct sock *tcp_check_req(struct sock *sk, struct sk_buff *skb, flg &= ~TCP_FLAG_SYN ; } +/* RFC 5961 section 3.2, as clarified by RFC 9293 section +* 3.10.7.4, requires a challenge ACK for a non-exact +* in-window RST in SYN-RECEIVED. +*/ +if ((flg &TCP_FLAG_RST ) && +TCP_SKB_CB (skb)->seq !=tcp_rsk (req)->rcv_nxt) { +tcp_reqsk_send_challenge_ack (sk, skb, req); +return NULL ; + } +/* RFC793: "second check the RST bit" and * "fourth, check the SYN bit" */
Signature · 1 line
2.53.0