[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250712-fix-double-perf-probe-unregister-v2-2-328b275672c5@quicinc.com>
Date: Sat, 12 Jul 2025 00:01:49 +0530
From: Aditya Chillara <quic_achillar@...cinc.com>
To: Steven Rostedt <rostedt@...dmis.org>, Ingo Molnar <mingo@...hat.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
CC: <linux-kernel@...r.kernel.org>,
Aditya Chillara
<quic_achillar@...cinc.com>
Subject: [PATCH v2 2/2] tracing: Prevent double unregister of tracepoint
probes
Prevent tracepoint_probe_unregister from being executed multiple times
for the same probe, which can cause issues with perf due to the lack
of error handling.
Return an error if the probe is not present in the list of probes.
Signed-off-by: Aditya Chillara <quic_achillar@...cinc.com>
---
kernel/tracepoint.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c
index ef42c1a1192053cc05b45ccb61358a4996453add..6e7b6dd3bdd5eb0ae92b2fd43767e8da942f2c18 100644
--- a/kernel/tracepoint.c
+++ b/kernel/tracepoint.c
@@ -232,7 +232,7 @@ func_add(struct tracepoint_func **funcs, struct tracepoint_func *tp_func,
static void *func_remove(struct tracepoint_func **funcs,
struct tracepoint_func *tp_func)
{
- int nr_probes = 0, nr_del = 0, i;
+ int nr_probes = 0, nr_del = 0, nr_tp_stub_del = 0, i;
struct tracepoint_func *old, *new;
old = *funcs;
@@ -244,13 +244,20 @@ static void *func_remove(struct tracepoint_func **funcs,
/* (N -> M), (N > 1, M >= 0) probes */
if (tp_func->func) {
for (nr_probes = 0; old[nr_probes].func; nr_probes++) {
- if ((old[nr_probes].func == tp_func->func &&
- old[nr_probes].data == tp_func->data) ||
- old[nr_probes].func == tp_stub_func)
+ if (old[nr_probes].func == tp_func->func &&
+ old[nr_probes].data == tp_func->data)
nr_del++;
+ else if (old[nr_probes].func == tp_stub_func)
+ nr_tp_stub_del++;
}
}
+ /* If there is nothing to delete, do not allow */
+ if (!nr_del)
+ return ERR_PTR(-ENOENT);
+
+ nr_del += nr_tp_stub_del;
+
/*
* If probe is NULL, then nr_probes = nr_del = 0, and then the
* entire entry will be removed.
--
2.34.1
Powered by blists - more mailing lists