netfilter: ctnetlink: fix conntrack creation race
authorPatrick McHardy <kaber@trash.net>
Mon, 24 Nov 2008 23:56:17 +0000 (15:56 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 24 Nov 2008 23:56:17 +0000 (15:56 -0800)
commitb54ad409fd09a395b839fb81f300880d76861c0e
tree580b23b89c04c85ad9795b37f81174e1bbb5311b
parent5147d14e995c097571d383fe1287fb33345a51ee
netfilter: ctnetlink: fix conntrack creation race

Conntrack creation through ctnetlink has two races:

- the timer may expire and free the conntrack concurrently, causing an
  invalid memory access when attempting to put it in the hash tables

- an identical conntrack entry may be created in the packet processing
  path in the time between the lookup and hash insertion

Hold the conntrack lock between the lookup and insertion to avoid this.

Reported-by: Zoltan Borbely <bozo@andrews.hu>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/netfilter/nf_conntrack_core.c
net/netfilter/nf_conntrack_netlink.c