blob: 37cad14784880b896ed33a6fec4df4ff7d16efff [file] [log] [blame]
From 86c9d99236b5a9713b08098f0f573b5c7539a9aa Mon Sep 17 00:00:00 2001
From: Ingo Molnar <mingo@elte.hu>
Date: Fri, 3 Jul 2009 08:30:07 -0500
Subject: [PATCH] net: plug a few races
commit 586a63770ab951230db869892deae1d09f839fdf in tip.
MUST-FIX: check the skbuff.c bit!
MUST-FIX: check the sched.c bit!
This doesn't look good. You declare it as a PER_CPU_LOCKED, but then
never use the extra lock to synchronize data.
Given that sock_proc_inuse_get() is a racy read anyway, the 'right' fix
would be to do something like:
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 93c4e06..68c401c 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -395,7 +395,7 @@ static void skb_release_head_state(struct sk_buff *skb)
secpath_put(skb->sp);
#endif
if (skb->destructor) {
- WARN_ON(in_irq());
+// WARN_ON(in_irq());
skb->destructor(skb);
}
#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
diff --git a/net/core/sock.c b/net/core/sock.c
index e1f6f22..f852c18 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2123,8 +2123,9 @@ static DECLARE_BITMAP(proto_inuse_idx, PROTO_INUSE_NR);
#ifdef CONFIG_NET_NS
void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
- int cpu = smp_processor_id();
+ int cpu = get_cpu();
per_cpu_ptr(net->core.inuse, cpu)->val[prot->inuse_idx] += val;
+ put_cpu();
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);
@@ -2170,7 +2171,9 @@ static DEFINE_PER_CPU(struct prot_inuse, prot_inuse);
void sock_prot_inuse_add(struct net *net, struct proto *prot, int val)
{
- __get_cpu_var(prot_inuse).val[prot->inuse_idx] += val;
+ int cpu = get_cpu();
+ per_cpu(prot_inuse, cpu).val[prot->inuse_idx] += val;
+ put_cpu();
}
EXPORT_SYMBOL_GPL(sock_prot_inuse_add);
--
1.7.1.1