mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 03:36:19 +00:00
tracepoint: check if the probe has been registered
Impact: fix kernel crash that can trigger during tracing If we try to remove a probe that has not been already registered, the tracepoint_entry_remove_probe() function will dereference a NULL pointer. Check the probe before removing it to avoid crashes. Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Acked-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca> Acked-by: Steven Rostedt <srostedt@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
parent
5209f08dc8
commit
f66af459a9
1 changed files with 8 additions and 0 deletions
|
@ -131,6 +131,9 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe)
|
||||||
|
|
||||||
old = entry->funcs;
|
old = entry->funcs;
|
||||||
|
|
||||||
|
if (!old)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
debug_print_probes(entry);
|
debug_print_probes(entry);
|
||||||
/* (N -> M), (N > 1, M >= 0) probes */
|
/* (N -> M), (N > 1, M >= 0) probes */
|
||||||
for (nr_probes = 0; old[nr_probes]; nr_probes++) {
|
for (nr_probes = 0; old[nr_probes]; nr_probes++) {
|
||||||
|
@ -388,6 +391,11 @@ int tracepoint_probe_unregister(const char *name, void *probe)
|
||||||
if (entry->rcu_pending)
|
if (entry->rcu_pending)
|
||||||
rcu_barrier_sched();
|
rcu_barrier_sched();
|
||||||
old = tracepoint_entry_remove_probe(entry, probe);
|
old = tracepoint_entry_remove_probe(entry, probe);
|
||||||
|
if (!old) {
|
||||||
|
printk(KERN_WARNING "Warning: Trying to unregister a probe"
|
||||||
|
"that doesn't exist\n");
|
||||||
|
goto end;
|
||||||
|
}
|
||||||
mutex_unlock(&tracepoints_mutex);
|
mutex_unlock(&tracepoints_mutex);
|
||||||
tracepoint_update_probes(); /* may update entry */
|
tracepoint_update_probes(); /* may update entry */
|
||||||
mutex_lock(&tracepoints_mutex);
|
mutex_lock(&tracepoints_mutex);
|
||||||
|
|
Loading…
Reference in a new issue