Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
need to grab module_mutex around kallsyms call to avoid assert
Browse files Browse the repository at this point in the history
Signed-off-by: Alan Maguire <alan.maguire@oracle.com>

Change-Id: I51a21fd747302c95d89efb5aa2b57af60384bad8
  • Loading branch information
alan-maguire committed May 1, 2018
1 parent 0360871 commit 40dce35
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions kernel/ktf_cov.c
Expand Up @@ -191,6 +191,9 @@ static int ktf_cov_init_symbol(void *data, const char *name,
if (!try_module_get(mod))
return 0;

/* module_mutex is grabbed by register_kprobe() */
mutex_unlock(&module_mutex);

/* We only care about symbols for cov-specified module. */
if (strcmp(mod->name, cov->kmap.key))
goto out;
Expand Down Expand Up @@ -244,6 +247,7 @@ static int ktf_cov_init_symbol(void *data, const char *name,
ktf_cov_entry_put(entry);

out:
mutex_lock(&module_mutex);
module_put(mod);
return 0;
}
Expand Down Expand Up @@ -577,7 +581,9 @@ int ktf_cov_enable(const char *name, unsigned int opts)
}
register_kretprobe_size =
ktf_symbol_size((unsigned long)register_kretprobe);
mutex_lock(&module_mutex);
kallsyms_on_each_symbol(ktf_cov_init_symbol, cov);
mutex_unlock(&module_mutex);
} else {
ktf_map_for_each_entry(entry, &cov_entry_map, kmap) {
if (entry->cov != cov)
Expand Down

0 comments on commit 40dce35

Please sign in to comment.