Skip to content

Commit

Permalink
Merge branch 'locking-urgent-for-linus' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/linux/kernel/git/tip/tip

Pull lockdep fix from Ingo Molnar:
 "A lockdep/modules unload race fix that can oops"

* 'locking-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  lockdep: Fix a race between /proc/lock_stat and module unload
  • Loading branch information
Linus Torvalds committed Jun 15, 2015
2 parents d37479a + cee34d8 commit 5bd2c28
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
3 changes: 2 additions & 1 deletion kernel/locking/lockdep.c
Original file line number Diff line number Diff line change
Expand Up @@ -3900,7 +3900,8 @@ static void zap_class(struct lock_class *class)
list_del_rcu(&class->hash_entry);
list_del_rcu(&class->lock_entry);

class->key = NULL;
RCU_INIT_POINTER(class->key, NULL);
RCU_INIT_POINTER(class->name, NULL);
}

static inline int within(const void *addr, void *start, unsigned long size)
Expand Down
22 changes: 17 additions & 5 deletions kernel/locking/lockdep_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,12 @@ static void seq_lock_time(struct seq_file *m, struct lock_time *lt)

static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
{
char name[39];
struct lock_class *class;
struct lockdep_subclass_key *ckey;
struct lock_class_stats *stats;
struct lock_class *class;
const char *cname;
int i, namelen;
char name[39];

class = data->class;
stats = &data->stats;
Expand All @@ -440,15 +442,25 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
if (class->subclass)
namelen -= 2;

if (!class->name) {
rcu_read_lock_sched();
cname = rcu_dereference_sched(class->name);
ckey = rcu_dereference_sched(class->key);

if (!cname && !ckey) {
rcu_read_unlock_sched();
return;

} else if (!cname) {
char str[KSYM_NAME_LEN];
const char *key_name;

key_name = __get_key_name(class->key, str);
key_name = __get_key_name(ckey, str);
snprintf(name, namelen, "%s", key_name);
} else {
snprintf(name, namelen, "%s", class->name);
snprintf(name, namelen, "%s", cname);
}
rcu_read_unlock_sched();

namelen = strlen(name);
if (class->name_version > 1) {
snprintf(name+namelen, 3, "#%d", class->name_version);
Expand Down

0 comments on commit 5bd2c28

Please sign in to comment.