]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: conntrack: fix race between confirmation and flush
authorPablo Neira Ayuso <pablo@netfilter.org>
Mon, 24 Nov 2014 23:14:47 +0000 (00:14 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 6 Jan 2015 21:27:45 +0000 (22:27 +0100)
commitd6f390d52e3032833c5bfc118ad5ec0c17b665d3
tree96c599dd113c822d1a666bc2a049c3778acd1aeb
parent842ed1e38739dfe054b8144d9e8f7d71020cd77c
netfilter: conntrack: fix race between confirmation and flush

Commit 07b62f7bf0752 ("netfilter: conntrack: fix race in
__nf_conntrack_confirm against get_next_corpse") aimed to resolve the
race condition between the confirmation (packet path) and the flush
command (from control plane). However, it introduced a crash when
several packets race to add a new conntrack, which seems easier to
reproduce when nf_queue is in place.

Fix this race, in __nf_conntrack_confirm(), by removing the CT
from unconfirmed list before checking the DYING bit. In case
race occured, re-add the CT to the dying list

This patch also changes the verdict from NF_ACCEPT to NF_DROP when
we lose race. Basically, the confirmation happens for the first packet
that we see in a flow. If you just invoked conntrack -F once (which
should be the common case), then this is likely to be the first packet
of the flow (unless you already called flush anytime soon in the past).
This should be hard to trigger, but better drop this packet, otherwise
we leave things in inconsistent state since the destination will likely
reply to this packet, but it will find no conntrack, unless the origin
retransmits.

The change of the verdict has been discussed in:
https://www.marc.info/?l=linux-netdev&m=141588039530056&w=2

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_conntrack_core.c