mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 02:32:09 -04:00
netfilter: nf_conntrack: fix a race in __nf_conntrack_confirm against nf_ct_get_next_corpse()
This race was triggered by a 'conntrack -F' command running in parallel to the insertion of a hash for a new connection. Losing this race led to a dead conntrack entry effectively blocking traffic for a particular connection until timeout or flushing the conntrack hashes again. Now the check for an already dying connection is done inside the lock. Signed-off-by: Joerg Marx <[email protected]> Signed-off-by: Patrick McHardy <[email protected]>
This commit is contained in:
parent
a1d7c1b4b8
commit
fc350777c7
2 changed files with 11 additions and 1 deletions
|
|
@ -424,6 +424,16 @@ __nf_conntrack_confirm(struct sk_buff *skb)
|
|||
|
||||
spin_lock_bh(&nf_conntrack_lock);
|
||||
|
||||
/* We have to check the DYING flag inside the lock to prevent
|
||||
a race against nf_ct_get_next_corpse() possibly called from
|
||||
user context, else we insert an already 'dead' hash, blocking
|
||||
further use of that particular connection -JM */
|
||||
|
||||
if (unlikely(nf_ct_is_dying(ct))) {
|
||||
spin_unlock_bh(&nf_conntrack_lock);
|
||||
return NF_ACCEPT;
|
||||
}
|
||||
|
||||
/* See if there's one in the list already, including reverse:
|
||||
NAT could have grabbed it without realizing, since we're
|
||||
not in the hash. If there is, we lost race. */
|
||||
|
|
|
|||
Loading…
Reference in a new issue