Skip to contentSkip to conversation

tracepoint: Check if the probe has been registered

PATCH Applied Frederic Weisbecker 4 participants 7 messages Oct 10, 2008 – Oct 27, 2008 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH 2/6 tracepoint: Check if the probe has been registered

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.

---
 kernel/tracepoint.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
kernel/tracepoint.c +8 -0
index f2b7c28..af8c856 100644
@@ -131,6 +131,9 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe)
 
 	old = entry->funcs;
 
+	if (!old)
+		return NULL;
+
 	debug_print_probes(entry);
 	/* (N -> M), (N > 1, M >= 0) 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)
 		rcu_barrier_sched();
 	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);
 	tracepoint_update_probes();		/* may update entry */
 	mutex_lock(&tracepoints_mutex);
Applied
#1 lore raw
Quoted 8 lines · Frederic Weisbecker

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.

---
 kernel/tracepoint.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

applied to tip/tracing/tracepoints, thanks Frederic!

Mathieu, Steve, any objections/observations?

Ingo

#2 lore raw
Quoted 7 lines · * Ingo Molnar ([email protected]) wrote:
Quoted 4 lines · Frederic Weisbecker

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.

Quoted 9 lines
Quoted 4 lines
---
 kernel/tracepoint.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

applied to tip/tracing/tracepoints, thanks Frederic!

Mathieu, Steve, any objections/observations?

Looks good to me. Thanks !

Mathieu

Quoted 1 line

Ingo

Signature · 2 lines
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F  BA06 3F25 A8FE 3BAE 9A68
maintainer
#3 lore raw
In reply to Ingo Molnar
Quoted 7 lines · Ingo Molnar
Quoted 4 lines · Frederic Weisbecker

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.

Quoted 8 lines
Quoted 4 lines
---
 kernel/tracepoint.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

applied to tip/tracing/tracepoints, thanks Frederic!

Mathieu, Steve, any objections/observations?

Hmm, my email was on the fritz for this one. I'll have to search for it on a mailing list web site to see the patch.

-- Steve

#6 lore raw
Quoted 8 lines · Frédéric Weisbecker

2008/10/10 Ingo Molnar <[email protected]>:

Quoted 1 line

applied to tip/tracing/tracepoints, thanks Frederic!

Hi Ingo.

Are you sure it has been applied? It seems to be lost in the sea :)

Thanks....

should be this one:

f66af45: tracepoint: check if the probe has been registered

Ingo