diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-07-03 08:30:07 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2009-07-29 23:30:40 +0200 |
commit | 586a63770ab951230db869892deae1d09f839fdf (patch) | |
tree | e4cb49c3cc5d043d7a4312233a6732ad6cbabde6 | |
parent | 5f6b01fb42386d9f33b2a759e59551d923a976ee (diff) | |
download | lwn-586a63770ab951230db869892deae1d09f839fdf.tar.gz lwn-586a63770ab951230db869892deae1d09f839fdf.zip |
net: plug a few races
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>
-rw-r--r-- | net/core/skbuff.c | 2 | ||||
-rw-r--r-- | net/core/sock.c | 7 |
2 files changed, 6 insertions, 3 deletions
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9e0597d189b0..27d2eb26d0fc 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 bbb25be7ddfe..04dbb0c80dd5 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2080,8 +2080,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); @@ -2127,7 +2128,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); |