]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.32.12/module-fix-__module_ref_addr.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.32.12 / module-fix-__module_ref_addr.patch
1 From mathieu.desnoyers@efficios.com Wed Apr 21 15:42:43 2010
2 From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 Date: Tue, 20 Apr 2010 10:38:10 -0400
4 Subject: module: fix __module_ref_addr()
5 To: Greg KH <greg@kroah.com>
6 Cc: Steven Rostedt <rostedt@goodmis.org>, Randy Dunlap <randy.dunlap@oracle.com>, Greg Kroah-Hartman <gregkh@suse.de>, Peter Zijlstra <a.p.zijlstra@chello.nl>, stable <stable@kernel.org>, Rusty Russell <rusty@rustcorp.com.au>, linux-kernel@vger.kernel.org, Eric Dumazet <dada1@cosmosbay.com>, Tejun Heo <tj@kernel.org>, Ingo Molnar <mingo@elte.hu>, Linus Torvalds <torvalds@linux-foundation.org>, Andrew Morton <akpm@linux-foundation.org>
7 Message-ID: <20100420143810.GC14622@Krystal>
8 Content-Disposition: inline
9
10 From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11
12 The __module_ref_addr() problem disappears in 2.6.34-rc kernels because these
13 percpu accesses were re-factored.
14
15 __module_ref_addr() should use per_cpu_ptr() to obfuscate the pointer
16 (RELOC_HIDE is needed for per cpu pointers).
17
18 This non-standard per-cpu pointer use has been introduced by commit
19 720eba31f47aeade8ec130ca7f4353223c49170f
20
21 It causes a NULL pointer exception on some configurations when CONFIG_TRACING is
22 enabled on 2.6.33. This patch fixes the problem (acknowledged by Randy who
23 reported the bug).
24
25 It did not appear to hurt previously because most of the accesses were done
26 through local_inc, which probably obfuscated the access enough that no compiler
27 optimizations were done. But with local_read() done when CONFIG_TRACING is
28 active, this becomes a problem. Non-CONFIG_TRACING is probably affected as well
29 (module.c contains local_set and local_read that use __module_ref_addr()), but I
30 guess nobody noticed because we've been lucky enough that the compiler did not
31 generate the inappropriate optimization pattern there.
32
33 This patch should be queued for the 2.6.29.x through 2.6.33.x stable branches.
34 (tested on 2.6.33.1 x86_64)
35
36 Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
37 Tested-by: Randy Dunlap <randy.dunlap@oracle.com>
38 CC: Eric Dumazet <dada1@cosmosbay.com>
39 CC: Rusty Russell <rusty@rustcorp.com.au>
40 CC: Peter Zijlstra <a.p.zijlstra@chello.nl>
41 CC: Tejun Heo <tj@kernel.org>
42 CC: Ingo Molnar <mingo@elte.hu>
43 CC: Andrew Morton <akpm@linux-foundation.org>
44 CC: Linus Torvalds <torvalds@linux-foundation.org>
45 CC: Greg Kroah-Hartman <gregkh@suse.de>
46 CC: Steven Rostedt <rostedt@goodmis.org>
47 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
48
49 ---
50 include/linux/module.h | 2 +-
51 1 file changed, 1 insertion(+), 1 deletion(-)
52
53 --- a/include/linux/module.h
54 +++ b/include/linux/module.h
55 @@ -455,7 +455,7 @@ void symbol_put_addr(void *addr);
56 static inline local_t *__module_ref_addr(struct module *mod, int cpu)
57 {
58 #ifdef CONFIG_SMP
59 - return (local_t *) (mod->refptr + per_cpu_offset(cpu));
60 + return (local_t *) per_cpu_ptr(mod->refptr, cpu);
61 #else
62 return &mod->ref;
63 #endif