]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
lockdep: fix kernel crash on module unload
authorArjan van de Ven <arjan@linux.intel.com>
Thu, 24 Jan 2008 06:00:45 +0000 (07:00 +0100)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Thu, 24 Jan 2008 16:01:09 +0000 (08:01 -0800)
Michael Wu noticed in his lkml post at

    http://marc.info/?l=linux-kernel&m=119396182726091&w=2

that certain wireless drivers ended up having their name in module
memory, which would then crash the kernel on module unload.

The patch he proposed was a bit clumsy in that it increased the size of
a lockdep entry significantly; the patch below tries another approach,
it checks, on module teardown, if the name of a class is in module space
and then zaps the class.  This is very similar to what we already do
with keys that are in module space.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Acked-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kernel/lockdep.c

index 4335f12a27c6367e8e264a1128050ea3df6e8415..e2c07ece367d1f9793f68c21a03a80701a09509f 100644 (file)
@@ -2932,7 +2932,7 @@ static void zap_class(struct lock_class *class)
 
 }
 
-static inline int within(void *addr, void *start, unsigned long size)
+static inline int within(const void *addr, void *start, unsigned long size)
 {
        return addr >= start && addr < start + size;
 }
@@ -2955,9 +2955,12 @@ void lockdep_free_key_range(void *start, unsigned long size)
                head = classhash_table + i;
                if (list_empty(head))
                        continue;
-               list_for_each_entry_safe(class, next, head, hash_entry)
+               list_for_each_entry_safe(class, next, head, hash_entry) {
                        if (within(class->key, start, size))
                                zap_class(class);
+                       else if (within(class->name, start, size))
+                               zap_class(class);
+               }
        }
 
        if (locked)