From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 640AE3E868F for ; Thu, 7 May 2026 10:28:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778149726; cv=none; b=YWx8x7wuKTUpsDpSBmL63BhSAefhqmN28fOPzlqWV/aNQ6hrCGfqxK6NR9iz9FopaIytdBz5JFqWtv8QeVSG2AgW2PPvi4bnQfJMiqy5JD6Xmoh4l7UKBddGqbuvvprBVhNcfn6v47V8Aiad5/AveDhGHveFMrUIN34DZvOsbZk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778149726; c=relaxed/simple; bh=JBG0yy3pAcb8cVsFnZatQnhZSv9Co0jaKCRJXqyWFtM=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=t7Gm/KrysMZGCpwmRVFTjKiRJKSzppPVAIZ+YTZiSZ53bv5Aklx5Ujhi2W95T/dFfDJautwM8JzMa4VZZ4oORKH1Azq4ek1pZ4ol8OKUSXzJct0+eRHBLpdFw608hksYdJDRZ8xfnKqRv/0UpSzESDKpgNzoL1iGUlBeS5jYwD0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=tDHUyITi; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="tDHUyITi" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8512FC2BCB2; Thu, 7 May 2026 10:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778149725; bh=JBG0yy3pAcb8cVsFnZatQnhZSv9Co0jaKCRJXqyWFtM=; h=Subject:To:Cc:From:Date:From; b=tDHUyITixfGRJC68Hg8EA37KAwsM6sCfpkoDGpf7dOpEWGKJ+d7ANbSQvR9SHGZhq DVXDxWhaol6AjKomgrOLLvDQx1AmUQ6qIrUCzv3qmfPgT1pW6sagdgaKcTJOIOLva8 ZkmfWjXJScsLCh/beOwrEp1MnuoM8Af8V+mGX2wM= Subject: FAILED: patch "[PATCH] tracepoint: balance regfunc() on func_add() failure in" failed to apply to 6.12-stable tree To: devnexen@gmail.com,mathieu.desnoyers@efficios.com,mhiramat@kernel.org,rostedt@goodmis.org Cc: From: Date: Thu, 07 May 2026 12:28:43 +0200 Message-ID: <2026050743-olive-survey-8b8f@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 6.12-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y git checkout FETCH_HEAD git cherry-pick -x fad217e16fded7f3c09f8637b0f6a224d58b5f2e # git commit -s git send-email --to '' --in-reply-to '2026050743-olive-survey-8b8f@gregkh' --subject-prefix 'PATCH 6.12.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From fad217e16fded7f3c09f8637b0f6a224d58b5f2e Mon Sep 17 00:00:00 2001 From: David Carlier Date: Mon, 13 Apr 2026 20:06:01 +0100 Subject: [PATCH] tracepoint: balance regfunc() on func_add() failure in tracepoint_add_func() When a tracepoint goes through the 0 -> 1 transition, tracepoint_add_func() invokes the subsystem's ext->regfunc() before attempting to install the new probe via func_add(). If func_add() then fails (for example, when allocate_probes() cannot allocate a new probe array under memory pressure and returns -ENOMEM), the function returns the error without calling the matching ext->unregfunc(), leaving the side effects of regfunc() behind with no installed probe to justify them. For syscall tracepoints this is particularly unpleasant: syscall_regfunc() bumps sys_tracepoint_refcount and sets SYSCALL_TRACEPOINT on every task. After a leaked failure, the refcount is stuck at a non-zero value with no consumer, and every task continues paying the syscall trace entry/exit overhead until reboot. Other subsystems providing regfunc()/unregfunc() pairs exhibit similarly scoped persistent state. Mirror the existing 1 -> 0 cleanup and call ext->unregfunc() in the func_add() error path, gated on the same condition used there so the unwind is symmetric with the registration. Fixes: 8cf868affdc4 ("tracing: Have the reg function allow to fail") Cc: stable@vger.kernel.org Cc: Masami Hiramatsu Cc: Mathieu Desnoyers Link: https://patch.msgid.link/20260413190601.21993-1-devnexen@gmail.com Signed-off-by: David Carlier Signed-off-by: Steven Rostedt (Google) diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 91905aa19294..dffef52a807b 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c @@ -300,6 +300,8 @@ static int tracepoint_add_func(struct tracepoint *tp, lockdep_is_held(&tracepoints_mutex)); old = func_add(&tp_funcs, func, prio); if (IS_ERR(old)) { + if (tp->ext && tp->ext->unregfunc && !static_key_enabled(&tp->key)) + tp->ext->unregfunc(); WARN_ON_ONCE(warn && PTR_ERR(old) != -ENOMEM); return PTR_ERR(old); }