Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 95aa1fe4 authored by David S. Miller's avatar David S. Miller
Browse files
parents b13bb2e9 941297f4
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -83,11 +83,12 @@ not detect it missed following items in original chain.
obj = kmem_cache_alloc(...);
lock_chain(); // typically a spin_lock()
obj->key = key;
atomic_inc(&obj->refcnt);
/*
 * we need to make sure obj->key is updated before obj->next
 * or obj->refcnt
 */
smp_wmb();
atomic_set(&obj->refcnt, 1);
hlist_add_head_rcu(&obj->obj_node, list);
unlock_chain(); // typically a spin_unlock()

@@ -159,6 +160,10 @@ out:
obj = kmem_cache_alloc(cachep);
lock_chain(); // typically a spin_lock()
obj->key = key;
/*
 * changes to obj->key must be visible before refcnt one
 */
smp_wmb();
atomic_set(&obj->refcnt, 1);
/*
 * insert obj in RCU way (readers might be traversing chain)
+1 −0
Original line number Diff line number Diff line
@@ -4044,6 +4044,7 @@ L: netfilter@vger.kernel.org
L:	coreteam@netfilter.org
W:	http://www.netfilter.org/
W:	http://www.iptables.org/
T:	git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git
S:	Supported
F:	include/linux/netfilter*
F:	include/linux/netfilter/
+18 −3
Original line number Diff line number Diff line
@@ -561,23 +561,38 @@ struct nf_conn *nf_conntrack_alloc(struct net *net,
		}
	}

	ct = kmem_cache_zalloc(nf_conntrack_cachep, gfp);
	/*
	 * Do not use kmem_cache_zalloc(), as this cache uses
	 * SLAB_DESTROY_BY_RCU.
	 */
	ct = kmem_cache_alloc(nf_conntrack_cachep, gfp);
	if (ct == NULL) {
		pr_debug("nf_conntrack_alloc: Can't alloc conntrack.\n");
		atomic_dec(&net->ct.count);
		return ERR_PTR(-ENOMEM);
	}

	/*
	 * Let ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.next
	 * and ct->tuplehash[IP_CT_DIR_REPLY].hnnode.next unchanged.
	 */
	memset(&ct->tuplehash[IP_CT_DIR_MAX], 0,
	       sizeof(*ct) - offsetof(struct nf_conn, tuplehash[IP_CT_DIR_MAX]));
	spin_lock_init(&ct->lock);
	atomic_set(&ct->ct_general.use, 1);
	ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple = *orig;
	ct->tuplehash[IP_CT_DIR_ORIGINAL].hnnode.pprev = NULL;
	ct->tuplehash[IP_CT_DIR_REPLY].tuple = *repl;
	ct->tuplehash[IP_CT_DIR_REPLY].hnnode.pprev = NULL;
	/* Don't set timer yet: wait for confirmation */
	setup_timer(&ct->timeout, death_by_timeout, (unsigned long)ct);
#ifdef CONFIG_NET_NS
	ct->ct_net = net;
#endif

	/*
	 * changes to lookup keys must be done before setting refcnt to 1
	 */
	smp_wmb();
	atomic_set(&ct->ct_general.use, 1);
	return ct;
}
EXPORT_SYMBOL_GPL(nf_conntrack_alloc);
+3 −2
Original line number Diff line number Diff line
@@ -330,7 +330,8 @@ static bool xt_osf_match_packet(const struct sk_buff *skb,
			fcount++;

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

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