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=1796388714; b=JhRur5+dgJKcQkxeTVXIomh6RxuNcrcJ2eehr9TdPYFgqWsS9ifYxpRJVPGKjysr4L3v uqDP0GatU+UAmuacowetKvH4RxHv4mMUl/YMguofq3INm/6OuzEvfDlC3/2IILxNGU4sU eP/ws4Oy64GoPxSSjMwL5XV4mysz7DXomsG3Z/cM0ZiCFk5m+HnkSUSfBAOjLlDniCLLF kOHtZaZ/rKLcIaSOqUTovHxmPD13iTzOVguH7uQ/IvFvmXsziU7SOJajCMSLrn+trvlwx DQrGpLbA7eDhzIGSFQXx2oIXUBL8zGGX8IfaEK/NF2l2Ty6O3Bztdu9VvSSzKJA0Ynw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796388714; 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=sXc953OsjoRGImy3CBXgIXqCCGxzv8abbQXWgAuLRDM=; b=KaIEBC2d5q0NcVUlxS5vnvpKjBfrSefLsqoXAJp0dnuY95lGDRDoHeFlGGduRLz+DSGC 2uFncTcHOlo8OszAHamyyrmSYJdLvHdAF8stIQxg32Lg3Nl2BYJWp5pLsEiOCsp74MfBC R79stJPWfyEg5f/FGObv79tYBdm/WV+7q7RT3G5tQ/R6YPK9euqt0s1CZCAiwbt2xZiiC oaJR2NtjoLqHAvx9WJCCKiNCSxccsajW+6HxOV+HYEw3UVFz5B6zC3ppsLiqgyaSQbzL/ 5ztiUy2NsR281yEj3yiMbBGYr1TDRlz9Rw4ITf6X7g/3FsQ7bACZybt8AvoLPEYhqtQ== 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=sss5NK9H; 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 D034F606A32C; Fri, 4 Dec 2026 12:51:54 +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=sss5NK9H Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1885B1F000C2; Fri, 4 Dec 2026 12:51:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796388714; bh=sXc953OsjoRGImy3CBXgIXqCCGxzv8abbQXWgAuLRDM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sss5NK9HsyJGzCqZiMcEIQ4Kb+ND8Ddctt9lv2O1tzqN4WjJWyKydENjYQKvQ7Ern DA9WSO5KaqwSwU9KY1LlOq0OciFeEt6D1z/9r5cbiSFnU39v7w4JBObZfInXm8to/t 7weCJYFgnohfKptrs8mRp1Y7vhXgG8lq5KvYSrDA= 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.1 0726/1059] tracing/probes: Enable newly appended probe when target event is enabled Date: Fri, 4 Dec 2026 19:04:17 +0900 Message-ID: <20261204100702.777139043@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: patches@lists.linux.dev 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: 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: Adapted to the older uprobe API: the filter callback keeps its ctx argument, and trace_uprobe_enable() uses tu->inode with uprobe_register()/uprobe_register_refctr() instead of struct uprobe pointers. The fprobe hunks are dropped. ] Signed-off-by: Sasha Levin --- kernel/trace/trace_uprobe.c | 71 +++++++++++++++++++++++-------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/kernel/trace/trace_uprobe.c b/kernel/trace/trace_uprobe.c index 4e50f405dc4d9..e7adb8d702612 100644 --- a/kernel/trace/trace_uprobe.c +++ b/kernel/trace/trace_uprobe.c @@ -442,6 +442,36 @@ static bool trace_uprobe_has_same_uprobe(struct trace_uprobe *orig, return false; } +typedef bool (*filter_func_t)(struct uprobe_consumer *self, + enum uprobe_filter_ctx ctx, + struct mm_struct *mm); + +#ifdef CONFIG_PERF_EVENTS +static bool uprobe_perf_filter(struct uprobe_consumer *uc, + enum uprobe_filter_ctx ctx, struct mm_struct *mm); +#else +#define uprobe_perf_filter NULL +#endif + +static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter) +{ + int ret; + + tu->consumer.filter = filter; + tu->inode = d_real_inode(tu->path.dentry); + + if (tu->ref_ctr_offset) + ret = uprobe_register_refctr(tu->inode, tu->offset, + tu->ref_ctr_offset, &tu->consumer); + else + ret = uprobe_register(tu->inode, tu->offset, &tu->consumer); + + if (ret) + tu->inode = NULL; + + return ret; +} + static int append_trace_uprobe(struct trace_uprobe *tu, struct trace_uprobe *to) { int ret; @@ -461,10 +491,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; } /* @@ -1076,29 +1118,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, - enum uprobe_filter_ctx ctx, - struct mm_struct *mm); - -static int trace_uprobe_enable(struct trace_uprobe *tu, filter_func_t filter) -{ - int ret; - - tu->consumer.filter = filter; - tu->inode = d_real_inode(tu->path.dentry); - - if (tu->ref_ctr_offset) - ret = uprobe_register_refctr(tu->inode, tu->offset, - tu->ref_ctr_offset, &tu->consumer); - else - ret = uprobe_register(tu->inode, tu->offset, &tu->consumer); - - if (ret) - tu->inode = NULL; - - return ret; -} - static void __probe_event_disable(struct trace_probe *tp) { struct trace_uprobe *tu; -- 2.53.0