module: fix __module_ref_addr()
A message that is not in the archive (sent off-list or not yet received): 20100325153436.GA22007@Krystal
(should really have CC'd lkml, here it is)
Quoted 65 lines · * Mathieu Desnoyers ([email protected]) wrote:
__module_ref_addr()should useper_cpu_ptr()to obfuscate the pointer (RELOC_HIDEis needed for per cpu pointers).This non-standard per-cpu pointer use has been introduced by commit
720eba31f47aeade8ec130ca7f4353223c49170fIt causes a NULL pointer exception on some configurations when
CONFIG_TRACINGis 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 withlocal_read()done whenCONFIG_TRACINGis active, this becomes a problem. Non-CONFIG_TRACING is probably affected as well (module.ccontainslocal_setandlocal_readthat 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 2.6.33.1
x86_64)The
__module_ref_addr()problem disappears in 2.6.34-rc kernels because these percpu accesses were re-factored.It makes me wonder about other non-standard uses of
per_cpu_offset: there is one inmodule.cand two inlockdep.c, which are still in 2.6.34-rc. This should probably be fixed by the code authors in separate patches.
lockdep.c: commit8e18257d29238311e82085152741f0c3aa18b74dmodule.c: commit6b588c18f8dacfa6d7957c33c5ff832096e752d3Signed-off-by Mathieu Desnoyers <[email protected]>Tested-by Randy Dunlap <[email protected]>CC Eric Dumazet <[email protected]>CC Rusty Russell <[email protected]>CC Peter Zijlstra <[email protected]>CC Tejun Heo <[email protected]>CC Ingo Molnar <[email protected]>CC Andrew Morton <[email protected]>CC Linus Torvalds <[email protected]>CC Greg Kroah-Hartman <[email protected]>--- include/linux/module.h | 2 +- kernel/module.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)Index:
linux-2.6-lttng/include/linux/module.h
===================================================================include/linux/module.h +1
-1@@ -467,7 +467,7 @@ void symbol_put_addr(void *addr);static inline local_t *__module_ref_addr (struct module *mod,int cpu) {#ifdef CONFIG_SMP -return (local_t *) (mod->refptr +per_cpu_offset (cpu)); +return (local_t *)per_cpu_ptr (mod->refptr, cpu);#else return &mod->ref;#endif Signature · 5 lines
-- Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com
Signature · 4 lines
Mathieu Desnoyers Operating System Efficiency R&D Consultant EfficiOS Inc. http://www.efficios.com