Skip to content

Commit d9d7b48

Browse files
Florian Westphalummakynes
authored andcommitted
netfilter: nft_flow_offload: clear tcp MAXACK flag before moving to slowpath
This state reset is racy, no locks are held here. Since commit 8437a62 ("netfilter: nft_flow_offload: set liberal tracking mode for tcp"), the window checks are disabled for normal data packets, but MAXACK flag is checked when validating TCP resets. Clear the flag so tcp reset validation checks are ignored. Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 375f222 commit d9d7b48

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

net/netfilter/nf_flow_table_core.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,20 @@ void flow_offload_route_init(struct flow_offload *flow,
161161
}
162162
EXPORT_SYMBOL_GPL(flow_offload_route_init);
163163

164-
static void flow_offload_fixup_tcp(struct ip_ct_tcp *tcp)
164+
static void flow_offload_fixup_tcp(struct nf_conn *ct)
165165
{
166+
struct ip_ct_tcp *tcp = &ct->proto.tcp;
167+
168+
spin_lock_bh(&ct->lock);
169+
/* Conntrack state is outdated due to offload bypass.
170+
* Clear IP_CT_TCP_FLAG_MAXACK_SET, otherwise conntracks
171+
* TCP reset validation will fail.
172+
*/
166173
tcp->seen[0].td_maxwin = 0;
174+
tcp->seen[0].flags &= ~IP_CT_TCP_FLAG_MAXACK_SET;
167175
tcp->seen[1].td_maxwin = 0;
176+
tcp->seen[1].flags &= ~IP_CT_TCP_FLAG_MAXACK_SET;
177+
spin_unlock_bh(&ct->lock);
168178
}
169179

170180
static void flow_offload_fixup_ct(struct nf_conn *ct)
@@ -176,7 +186,7 @@ static void flow_offload_fixup_ct(struct nf_conn *ct)
176186
if (l4num == IPPROTO_TCP) {
177187
struct nf_tcp_net *tn = nf_tcp_pernet(net);
178188

179-
flow_offload_fixup_tcp(&ct->proto.tcp);
189+
flow_offload_fixup_tcp(ct);
180190

181191
timeout = tn->timeouts[ct->proto.tcp.state];
182192
timeout -= tn->offload_timeout;

0 commit comments

Comments
 (0)