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=1796379449; b=KT7w9huIt/hmjuDa6C22SgPHKyKcxGr/EfFdtl7Lj6jVlM0ai3DgbGvwEN3FTpMt4whL tL8g7S0I/XG/Olr6s93y6Gzk/M1Lyj3BcJVmyMlUMOFzz/COBb+WBzirIle9DaeNZU6xZ 0CDtApnbKr5J8Na1ZDIh5nWuH9MqQ0IDEBPs9v4qtDQl5hcXIcxi581dBq9o0qZPEr3XV XBdLIzZAzNn2w15mSPopthxgW8Rr4+JGH6uLrdBq7gtMVibTRPihqdhlq/nVgwW/Np+de 9yuP3NdeTAblukRto5v5iHiSg6dVssbjX0Db3CAUemfy9JzK2Wndt5EVXZ1Ev3IMaaQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796379449; 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=HM1Ve5/WpO1vXth8bPVR385PBvYbNlEsl1UjUfXzQsg=; b=L0pgi9l/l4v1PDBX0rwx6LAFcMMuU9UcBObmewspRWGJ7KfOb3vBp8t9/m+4kCb+zYVw 6RfULcr8/+lUW40PKEVb2bcjl71DzHtRYRDQobKVEKI5u5uIInLpo1/EUSTl8um5Sufi3 XaErHMJ6tXK9eo9Q8O9X6sjRGnacLzaSby4IQIGJPyy8gWgiSQjjVZ7hZDpnWFk/lWp/g psh6SessKIuMHlpMMjo9gOCaRsyux3WuOm44Znv8AMlMQ1eaCtcLfzwZx5ut0+5qpb/bf b0GlxNtqB77DvlCnpyZ4SX45TgFQF3nSaUOykRXP4EI8+qgSknb3AdxgcZXitUY1EuQ== 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="vxD/OtM3"; 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 C7ADF606A322; Fri, 4 Dec 2026 10:17:29 +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=vxD/OtM3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DC8E71F000C2; Fri, 4 Dec 2026 10:17:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796379449; bh=HM1Ve5/WpO1vXth8bPVR385PBvYbNlEsl1UjUfXzQsg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=vxD/OtM3DvxMzdaA5A00/2+m0uFo0H5U4eBq3Vlj8hLJ9EQwrI/CJ014juIDpc7+N NRPEegPocbcx4Sx7qIuqxjli4dNAtL4FbFo24izf1ykyGWnYMLiqyalmce1OXC00DB FUEpmSiNIB8/WioHp83nclZvy6bafA/QsGvTOlv8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, "Masami Hiramatsu (Google)" , Sasha Levin Subject: [PATCH 6.12 033/555] tracing/probes: Enable newly appended probe when target event is enabled Date: Fri, 4 Dec 2026 19:01:16 +0900 Message-ID: <20261204100606.558969075@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Masami Hiramatsu (Google) [ Upstream commit 72d3a5cb0cd7335553549aaffecc683e3ecc0c43 ] Unlike kprobe events, fprobe and uprobe events only register their underlying probes when the trace event is enabled. When a new probe is appended to an existing multiprobe fprobe or uprobe event that is already enabled, the appended probe is linked into the event's probe list without being registered. As a result, the newly appended probe never fires until the event is disabled and re-enabled. Moreover, disabling an fprobe event calls unregister_fprobe() on the unregistered fprobe, and opening or closing a perf event on an enabled uprobe event dereferences a NULL tu->uprobe in uprobe_apply(). Register and enable the newly appended fprobe or uprobe immediately when the target event is already enabled. Link: https://lore.kernel.org/all/179455849798.403392.135678786198324285.stgit@devnote2/ Fixes: 41af3cf587f4 ("tracing/uprobe: Add multi-probe per uprobe event support") Fixes: 2db832ec9090 ("tracing: fprobe-events: Register fprobe-events only when it is enabled") Cc: stable@vger.kernel.org Signed-off-by: Masami Hiramatsu (Google) [ sashal: Dropped the fprobe hunks, which have no counterpart here, and kept only the uprobe changes, moving trace_uprobe_enable() and filter_func_t earlier with a forward declaration of uprobe_perf_filter. ] Signed-off-by: Sasha Levin --- kernel/trace/trace_uprobe.c | 56 ++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index cf5dc4b456eee..d18669586afab 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -443,6 +443,28 @@ static bool trace_uprobe_has_same_uprobe(struct trace_uprobe *orig, return false; } +typedef bool (*filter_func_t)(struct uprobe_consumer *self, struct mm_struct *mm); + +#ifdef CONFIG_PERF_EVENTS +static bool uprobe_perf_filter(struct uprobe_consumer *uc, struct mm_struct *mm); +#else +#define uprobe_perf_filter NULL +#endif + +static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter) +{ + struct inode *inode = d_real_inode(tu->path.dentry); + struct uprobe *uprobe; + + tu->consumer.filter = filter; + uprobe = uprobe_register(inode, tu->offset, tu->ref_ctr_offset, &tu->consumer); + if (IS_ERR(uprobe)) + return PTR_ERR(uprobe); + + tu->uprobe = uprobe; + return 0; +} + static int append_trace_uprobe(struct trace_uprobe *tu, struct trace_uprobe *to) { int ret; @@ -462,10 +484,22 @@ static int append_trace_uprobe(struct trace_uprobe *tu, struct trace_uprobe *to) /* Append to existing event */ ret = trace_probe_append(&tu->tp, &to->tp); - if (!ret) - dyn_event_add(&tu->devent, trace_probe_event_call(&tu->tp)); + if (ret) + return ret; - return ret; + if (trace_probe_is_enabled(&tu->tp)) { + ret = trace_uprobe_enable(tu, + trace_probe_test_flag(&tu->tp, TP_FLAG_PROFILE) ? + uprobe_perf_filter : NULL); + if (ret) { + trace_probe_unlink(&tu->tp); + return ret; + } + } + + dyn_event_add(&tu->devent, trace_probe_event_call(&tu->tp)); + + return 0; } /* @@ -1104,22 +1138,6 @@ print_uprobe_event(struct trace_iterator *iter, int flags, struct trace_event *e return trace_handle_return(s); } -typedef bool (*filter_func_t)(struct uprobe_consumer *self, struct mm_struct *mm); - -static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter) -{ - struct inode *inode = d_real_inode(tu->path.dentry); - struct uprobe *uprobe; - - tu->consumer.filter = filter; - uprobe = uprobe_register(inode, tu->offset, tu->ref_ctr_offset, &tu->consumer); - if (IS_ERR(uprobe)) - return PTR_ERR(uprobe); - - tu->uprobe = uprobe; - return 0; -} - static void __probe_event_disable(struct trace_probe *tp) { struct trace_uprobe *tu; -- 2.53.0