From: Michael Wu <flamingice@sourmilk.net>
To: "Luis R. Rodriguez" <mcgrof@gmail.com>
Cc: linux-wireless <linux-wireless@vger.kernel.org>,
"John W. Linville" <linville@tuxdriver.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Johannes Berg <johannes@sipsolutions.net>,
linux-kernel@vger.kernel.org
Subject: Re: RFC: Reproducible oops with lockdep on count_matching_names()
Date: Thu, 1 Nov 2007 19:26:02 -0400 [thread overview]
Message-ID: <200711011926.07641.flamingice@sourmilk.net> (raw)
In-Reply-To: <20071101191716.GA3201@pogo>
[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]
On Thursday 01 November 2007 15:17:16 Luis R. Rodriguez wrote:
> mcgrof@pogo:~/devel/wireless-2.6$ git-describe
> v2.6.24-rc1-146-g2280253
>
> So I hit segfault with lockdep on count_matching_names() on the
> strcmp() multiple times now. This is reproducible and with different
> wireless drivers.
>
I've found the problem. It appears to be in lockdep. struct lock_class has a
const char *name field which points to a statically allocated string that
comes from the code which uses the lock. If that code/string is in a module
and gets unloaded, the pointer in |name| is no longer valid. Next time this
field is dereferenced (count_matching_names, in this case), we crash.
The following patch fixes the issue but there's probably a better way.
-Michael Wu
---
diff --git a/include/linux/lockdep.h b/include/linux/lockdep.h
index 4c4d236..2aa0d35 100644
--- a/include/linux/lockdep.h
+++ b/include/linux/lockdep.h
@@ -114,7 +114,7 @@ struct lock_class {
*/
unsigned long ops;
- const char *name;
+ char name[128];
int name_version;
#ifdef CONFIG_LOCK_STAT
diff --git a/kernel/lockdep.c b/kernel/lockdep.c
index 55fe0c7..63c4d8f 100644
--- a/kernel/lockdep.c
+++ b/kernel/lockdep.c
@@ -768,7 +768,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int
subclass, int force)
class = lock_classes + nr_lock_classes++;
debug_atomic_inc(&nr_unused_locks);
class->key = key;
- class->name = lock->name;
+ strcpy(class->name, lock->name);
class->subclass = subclass;
INIT_LIST_HEAD(&class->lock_entry);
INIT_LIST_HEAD(&class->locks_before);
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 194 bytes --]
next parent reply other threads:[~2007-11-02 0:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071101191716.GA3201@pogo>
2007-11-01 23:26 ` Michael Wu [this message]
2007-11-02 10:58 ` Peter Zijlstra
2007-11-03 19:58 ` Luis R. Rodriguez
2007-11-03 20:06 ` Michael Buesch
2007-11-05 12:00 ` Peter Zijlstra
2007-11-05 12:23 ` Pekka Enberg
2007-11-05 13:03 ` Michael Buesch
2007-11-05 13:56 ` Pekka Enberg
2007-11-05 14:26 ` Michael Buesch
2007-11-05 18:47 ` Christoph Lameter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200711011926.07641.flamingice@sourmilk.net \
--to=flamingice@sourmilk.net \
--cc=johannes@sipsolutions.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=linville@tuxdriver.com \
--cc=mcgrof@gmail.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome