Skip to content

Commit 95aa1fe

Browse files
committed
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6
2 parents b13bb2e + 941297f commit 95aa1fe

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

Documentation/RCU/rculist_nulls.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,12 @@ not detect it missed following items in original chain.
8383
obj = kmem_cache_alloc(...);
8484
lock_chain(); // typically a spin_lock()
8585
obj->key = key;
86-
atomic_inc(&obj->refcnt);
8786
/*
8887
* we need to make sure obj->key is updated before obj->next
88+
* or obj->refcnt
8989
*/
9090
smp_wmb();
91+
atomic_set(&obj->refcnt, 1);
9192
hlist_add_head_rcu(&obj->obj_node, list);
9293
unlock_chain(); // typically a spin_unlock()
9394

@@ -159,6 +160,10 @@ out:
159160
obj = kmem_cache_alloc(cachep);
160161
lock_chain(); // typically a spin_lock()
161162
obj->key = key;
163+
/*
164+
* changes to obj->key must be visible before refcnt one
165+
*/
166+
smp_wmb();
162167
atomic_set(&obj->refcnt, 1);
163168
/*
164169
* insert obj in RCU way (readers might be traversing chain)

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,6 +4044,7 @@ L: netfilter@vger.kernel.org
40444044
L: coreteam@netfilter.org
40454045
W: http://www.netfilter.org/
40464046
W: http://www.iptables.org/
4047+
T: git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git
40474048
S: Supported
40484049
F: include/linux/netfilter*
40494050
F: include/linux/netfilter/

net/netfilter/nf_conntrack_core.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,23 +561,38 @@ struct nf_conn *nf_conntrack_alloc(struct net *net,
561561
}
562562
}
563563

564-
ct = kmem_cache_zalloc(nf_conntrack_cachep, gfp);
564+
/*
565+
* Do not use kmem_cache_zalloc(), as this cache uses
566+
* SLAB_DESTROY_BY_RCU.
567+
*/
568+
ct = kmem_cache_alloc(nf_conntrack_cachep, gfp);
565569
if (ct == NULL) {
566570
pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n");
567571
atomic_dec(&net->ct.count);
568572
return ERR_PTR(-ENOMEM);
569573
}
570-
574+
/*
575+
* Let ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.next
576+
* and ct->tuplehash[IP_CT_DIR_REPLY].hnnode.next unchanged.
577+
*/
578+
memset(&ct->tuplehash[IP_CT_DIR_MAX], 0,
579+
sizeof(*ct) - offsetof(struct nf_conn, tuplehash[IP_CT_DIR_MAX]));
571580
spin_lock_init(&ct->lock);
572-
atomic_set(&ct->ct_general.use, 1);
573581
ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig;
582+
ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.pprev = NULL;
574583
ct->tuplehash[IP_CT_DIR_REPLY].tuple = *repl;
584+
ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL;
575585
/* Don't set timer yet: wait for confirmation */
576586
setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct);
577587
#ifdef CONFIG_NET_NS
578588
ct->ct_net = net;
579589
#endif
580590

591+
/*
592+
* changes to lookup keys must be done before setting refcnt to 1
593+
*/
594+
smp_wmb();
595+
atomic_set(&ct->ct_general.use, 1);
581596
return ct;
582597
}
583598
EXPORT_SYMBOL_GPL(nf_conntrack_alloc);

net/netfilter/xt_osf.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,8 @@ static bool xt_osf_match_packet(const struct sk_buff *skb,
330330
fcount++;
331331

332332
if (info->flags & XT_OSF_LOG)
333-
nf_log_packet(p->hooknum, 0, skb, p->in, p->out, NULL,
333+
nf_log_packet(p->family, p->hooknum, skb,
334+
p->in, p->out, NULL,
334335
"%s [%s:%s] : %pi4:%d -> %pi4:%d hops=%d\n",
335336
f->genre, f->version, f->subtype,
336337
&ip->saddr, ntohs(tcp->source),
@@ -345,7 +346,7 @@ static bool xt_osf_match_packet(const struct sk_buff *skb,
345346
rcu_read_unlock();
346347

347348
if (!fcount && (info->flags & XT_OSF_LOG))
348-
nf_log_packet(p->hooknum, 0, skb, p->in, p->out, NULL,
349+
nf_log_packet(p->family, p->hooknum, skb, p->in, p->out, NULL,
349350
"Remote OS is not known: %pi4:%u -> %pi4:%u\n",
350351
&ip->saddr, ntohs(tcp->source),
351352
&ip->daddr, ntohs(tcp->dest));

0 commit comments

Comments
 (0)