netfilter: ctnetlink: fix missing refcount increment during dumps
authorPablo Neira Ayuso <[email protected]>
Mon, 24 Jan 2011 18:01:07 +0000 (19:01 +0100)
committerPatrick McHardy <[email protected]>
Mon, 24 Jan 2011 18:01:07 +0000 (19:01 +0100)
In 13ee6ac netfilter: fix race in conntrack between dump_table and
destroy, we recovered spinlocks to protect the dump of the conntrack
table according to reports from Stephen and acknowledgments on the
issue from Eric.

In that patch, the refcount bump that allows to keep a reference
to the current ct object was removed. However, we still decrement
the refcount for that object in the output path of
ctnetlink_dump_table():

        if (last)
                nf_ct_put(last)

Cc: Stephen Hemminger <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Acked-by: Eric Dumazet <[email protected]>
Signed-off-by: Patrick McHardy <[email protected]>
net/netfilter/nf_conntrack_netlink.c

index 93297aaceb2b3d48e307bfb74549661bfaeda27f..eead9db6f899ad71869013dec0b3e2de480361a1 100644 (file)
@@ -667,6 +667,7 @@ restart:
                        if (ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).pid,
                                                cb->nlh->nlmsg_seq,
                                                IPCTNL_MSG_CT_NEW, ct) < 0) {
+                               nf_conntrack_get(&ct->ct_general);
                                cb->args[1] = (unsigned long)ct;
                                goto out;
                        }