[lkml]   [2010]   [Apr]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[124/139] module: fix __module_ref_addr()
2.6.33-stable review patch.  If anyone has any objections, please let us know.


From: Mathieu Desnoyers <>

The __module_ref_addr() problem disappears in 2.6.34-rc kernels because these
percpu accesses were re-factored.

__module_ref_addr() should use per_cpu_ptr() to obfuscate the pointer
(RELOC_HIDE is needed for per cpu pointers).

This non-standard per-cpu pointer use has been introduced by commit

It causes a NULL pointer exception on some configurations when CONFIG_TRACING is
enabled on 2.6.33. This patch fixes the problem (acknowledged by Randy who
reported the bug).

It did not appear to hurt previously because most of the accesses were done
through local_inc, which probably obfuscated the access enough that no compiler
optimizations were done. But with local_read() done when CONFIG_TRACING is
active, this becomes a problem. Non-CONFIG_TRACING is probably affected as well
(module.c contains local_set and local_read that use __module_ref_addr()), but I
guess nobody noticed because we've been lucky enough that the compiler did not
generate the inappropriate optimization pattern there.

This patch should be queued for the 2.6.29.x through 2.6.33.x stable branches.
(tested on x86_64)

Signed-off-by: Mathieu Desnoyers <>
Tested-by: Randy Dunlap <>
CC: Eric Dumazet <>
CC: Rusty Russell <>
CC: Peter Zijlstra <>
CC: Tejun Heo <>
CC: Ingo Molnar <>
CC: Andrew Morton <>
CC: Linus Torvalds <>
CC: Greg Kroah-Hartman <>
CC: Steven Rostedt <>
Signed-off-by: Greg Kroah-Hartman <>

include/linux/module.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -457,7 +457,7 @@ void symbol_put_addr(void *addr);
static inline local_t *__module_ref_addr(struct module *mod, int cpu)
- return (local_t *) (mod->refptr + per_cpu_offset(cpu));
+ return (local_t *) per_cpu_ptr(mod->refptr, cpu);
return &mod->ref;

 \ /
  Last update: 2010-04-22 22:13    [W:0.360 / U:11.108 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site