netfilter: conntrack: handle tcp challenge acks during connection reuse
authorFlorian Westphal <fw@strlen.de>
Wed, 11 Jan 2023 13:42:32 +0000 (14:42 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 17 Jan 2023 22:00:06 +0000 (23:00 +0100)
commitc410cb974f2ba562920ecb8492ee66945dcf88af
treeaf479529f15ee899a919e0a853b56f45555d8a8f
parent1f3bd64ad921f051254591fbed04fd30b306cde6
netfilter: conntrack: handle tcp challenge acks during connection reuse

When a connection is re-used, following can happen:
[ connection starts to close, fin sent in either direction ]
 > syn   # initator quickly reuses connection
 < ack   # peer sends a challenge ack
 > rst   # rst, sequence number == ack_seq of previous challenge ack
 > syn   # this syn is expected to pass

Problem is that the rst will fail window validation, so it gets
tagged as invalid.

If ruleset drops such packets, we get repeated syn-retransmits until
initator gives up or peer starts responding with syn/ack.

Before the commit indicated in the "Fixes" tag below this used to work:

The challenge-ack made conntrack re-init state based on the challenge
ack itself, so the following rst would pass window validation.

Add challenge-ack support: If we get ack for syn, record the ack_seq,
and then check if the rst sequence number matches the last ack number
seen in reverse direction.

Fixes: c7aab4f17021 ("netfilter: nf_conntrack_tcp: re-init for syn packets only")
Reported-by: Michal Tesar <mtesar@redhat.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_proto_tcp.c