lkml.org 
[lkml]   [2009]   [Sep]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH] fix error handling in load_module()
Hello, Rusty.

Rusty Russell wrote:
>> My reverse engineering of the secret, undocumented percpu_modfree()
>> indicates that its mad inventor intended that percpu_modfree(NULL) be a
>> valid thing to do.
>
> Yes, percpu_modfree() should handle NULL. If it doesn't, that's the bug.

Hmm... It seems the report was against pre-2.6.32-rcX window. ppc is
still using the original percpu_modfree() and I don't think the it
ever supported NULL free. In the current linus tree, the triggering
BUG() would be at line 500 which is inside percpu_modfree() which
checks @freeme matches any allocated address and if not triggers
BUG().

I think something like the following should fix it.

kernel/module.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/kernel/module.c b/kernel/module.c
index 05ce49c..eed1f9e 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -490,6 +490,9 @@ static void percpu_modfree(void *freeme)
void *ptr = __per_cpu_start + block_size(pcpu_size[0]);
int cpu;

+ if (unlikely(!freeme))
+ return;
+
/* First entry is core kernel percpu data. */
for (i = 1; i < pcpu_num_used; ptr += block_size(pcpu_size[i]), i++) {
if (ptr == freeme) {
--
tejun


\
 
 \ /
  Last update: 2009-09-21 16:27    [W:0.209 / U:0.116 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site