From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796388632; b=WyCoSB3V7SwZvFwVFXHuFUfFHZq7hV/OK/XuyYpRCt4oFJ7fgt5psWU1LojYdeGRlqJd 142CrOV4eckQ9DcTMbEu6x7EiSSsgBXxB7bpvppZGCz2RjY/6pCfXYpcs1Yp8Yfa0E4V2 yPga/y1WQUQR/2JSCmbiMnvP/oAhKTFaq6qipwkHuJrA7huX8cHGLOUdAeG2v8yI1Wkyc ihw/DvMfRlMAtdqSasRA0ksZX3GWk5S+54dg/6A6WudQ858KNhr06h8X/rkllvqo9iUws 8DKoc8DjtiaSTuOe8PViZWluc/v/EYXQvPFlPtYaUr27pQpR0AEzAgfT5PfIeo93zLA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388632; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=3jeoO+vVqKUrTXJx/hJgk6gCdaJ8l09srbXHTdIq/iI=; b=AOMuzPwO2hrhOBOuMAPPQYudhOyI046q8dG55EjuY69Emcfnd1nO+xwlnCWoMfrPwMdK 6p+7KTOFvhJoNKsKD6X7XH8MZ2lcD9FOmSq6gj82JDnFB3z1K83mBbFoEfpUlkVK8bZyQ tDckWPNI7zwx1i1Kk+iWcWD8j6UA3ekC8fHKaieAHS1nHPwB2lXTLzjixkedByzhHrAPp BynZ+JVn6oRhh/SlI1VHiruBymeiDPfya9WU8i4UuNcoWgYz1l7c7FSiS5kZVlRe8gjFz j8G+OOkUoU3BsqbQNn7f4CuxBXdu0iGwjkDVzQyOR5O3draElblDwaduWJqIhfDZvMQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ZYkPaCPh; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 013F2606A32D; Fri, 4 Dec 2026 12:50:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=ZYkPaCPh Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A7271F00931; Fri, 4 Dec 2026 12:50:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388631; bh=3jeoO+vVqKUrTXJx/hJgk6gCdaJ8l09srbXHTdIq/iI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZYkPaCPhBljgTJ5YmqUc9yrgtgUGSGF3i6vPX12ESe46nd3vEaWHVyEod0JRDquzQ +jKDqeF/eHRQeMnyohRsIGBqp2L+nUT43EImUzSCNOiEB7fHFVHcJt2DVhDS719GWM gMzJI1yfLkqyOPqdOGEM/3mHhGVrN+kPg5FDBM0M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Carlier , "Masami Hiramatsu (Google)" , Sasha Levin Subject: [PATCH 6.1 0695/1059] tracing/eprobe: Install the trigger for every instance that enables the eprobe Date: Fri, 4 Dec 2026 19:03:46 +0900 Message-ID: <20261204100701.984859098@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Carlier [ Upstream commit be94710b1f6ba1bea33e73129c110af80e999b2d ] The eprobe trigger lives in the instance of the enabling file, but it is only added when the eprobe is first enabled and only removed when the last file goes away. A second instance then records nothing, and the first instance's trigger is left behind once the eprobe is disabled there, so the eprobe can be deleted while that trigger still uses it. Add and remove the trigger for each file. The file is never NULL here, so warn if it is and drop the dead perf paths. Link: https://lore.kernel.org/all/20261107101233.151434-1-devnexen@gmail.com/ Fixes: 7491e2c44278 ("tracing: Add a probe that attaches to trace events") Cc: stable@vger.kernel.org Signed-off-by: David Carlier Signed-off-by: Masami Hiramatsu (Google) Signed-off-by: Sasha Levin --- kernel/trace/trace_eprobe.c | 56 ++++++++++++------------------------- 1 file changed, 18 insertions(+), 38 deletions(-) diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c index 8d9cd7617fc75..7de2f905e5970 100644 --- a/kernel/trace/trace_eprobe.c +++ b/kernel/trace/trace_eprobe.c @@ -746,37 +746,32 @@ static int enable_trace_eprobe(struct trace_event_call *call, { struct trace_probe *tp; struct trace_eprobe *ep; - bool enabled; int ret = 0; int cnt = 0; + if (WARN_ON_ONCE(!file)) + return -EINVAL; + tp = trace_probe_primary_from_call(call); if (WARN_ON_ONCE(!tp)) return -ENODEV; - enabled = trace_probe_is_enabled(tp); /* This also changes "enabled" state */ - if (file) { - ret = trace_probe_add_file(tp, file); - if (ret) - return ret; - } else - trace_probe_set_flag(tp, TP_FLAG_PROFILE); - - if (enabled) - return 0; + ret = trace_probe_add_file(tp, file); + if (ret) + return ret; + /* The trigger lives in the instance of the file, add it for each file */ for_each_trace_eprobe_tp(ep, tp) { ret = enable_eprobe(ep, file); if (ret) break; - enabled = true; cnt++; } if (ret) { /* Failed to enable one of them. Roll back all */ - if (enabled) { + if (cnt) { /* * It's a bug if one failed for something other than memory * not being available but another eprobe succeeded. @@ -789,10 +784,7 @@ static int enable_trace_eprobe(struct trace_event_call *call, break; } } - if (file) - trace_probe_remove_file(tp, file); - else - trace_probe_clear_flag(tp, TP_FLAG_PROFILE); + trace_probe_remove_file(tp, file); } return ret; @@ -804,33 +796,21 @@ static int disable_trace_eprobe(struct trace_event_call *call, struct trace_probe *tp; struct trace_eprobe *ep; + if (WARN_ON_ONCE(!file)) + return -EINVAL; + tp = trace_probe_primary_from_call(call); if (WARN_ON_ONCE(!tp)) return -ENODEV; - if (file) { - if (!trace_probe_get_file_link(tp, file)) - return -ENOENT; - if (!trace_probe_has_single_file(tp)) - goto out; - trace_probe_clear_flag(tp, TP_FLAG_TRACE); - } else - trace_probe_clear_flag(tp, TP_FLAG_PROFILE); + if (!trace_probe_get_file_link(tp, file)) + return -ENOENT; - if (!trace_probe_is_enabled(tp)) { - for_each_trace_eprobe_tp(ep, tp) - disable_eprobe(ep, file->tr); - } + for_each_trace_eprobe_tp(ep, tp) + disable_eprobe(ep, file->tr); - out: - if (file) - /* - * Synchronization is done in below function. For perf event, - * file == NULL and perf_trace_event_unreg() calls - * tracepoint_synchronize_unregister() to ensure synchronize - * event. We don't need to care about it. - */ - trace_probe_remove_file(tp, file); + /* Synchronization is done in below function. */ + trace_probe_remove_file(tp, file); return 0; } -- 2.53.0