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 A8EF73C5DDD for ; Thu, 7 May 2026 10:27:38 +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=1778149658; cv=none; b=Opsmz1rq14VSAqMC0j0XLljKEDH7G56hJ32LDWP5L+zjmeB1qiDKnZ/jtllC450VeBok0SChdrj2EjaFeioSHGGVkvMa7L12yBp6tixXRNY3RPXXkHKEDdG6cbzvbTyMdjk2h3Y2KLD90eoxVkxx9RToREbiKrp8KC820vr1A9Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778149658; c=relaxed/simple; bh=FxosIv73XFHnDgfuwm0wWT6dUdRmdRt4F7dfAGXU3+8=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=MCHlenf7T3FW/+ki3iCDh2aH2NeJHEwctAxMKSLJIoJbN3TRbAlSHm/FSYRZJYWlAfDvrOs870Pb6QBhg10XWlQA7xyF2yfyQ8Q0u/5sudzjgQ7iq8rNl9G2zBF64FcdDI+fnGmRzsXahq1g8AiYcArVI4PBTtHtxkd2FvSj/eg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1IpVtiya; 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="1IpVtiya" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DBBDBC2BCB2; Thu, 7 May 2026 10:27:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1778149658; bh=FxosIv73XFHnDgfuwm0wWT6dUdRmdRt4F7dfAGXU3+8=; h=Subject:To:Cc:From:Date:From; b=1IpVtiyaYIm5sC3H+Bry+4zbNpXJ9ARajbbYvIkwe8mpT3V6458VAEPG5AJeYcm6I KWf4jTA6DRH1qJhYLPOZ3PF5zjmYh836Xq2Zx1TLkJhXt7pNBQFrkW9M2nxh5lL5l0 KDR0zLDUKnmeJ0VKWYwu0n7TngtTK2c1dk5s0yP0= Subject: FAILED: patch "[PATCH] tracepoint: balance regfunc() on func_add() failure in" failed to apply to 6.6-stable tree To: devnexen@gmail.com,mathieu.desnoyers@efficios.com,mhiramat@kernel.org,rostedt@goodmis.org Cc: From: Date: Thu, 07 May 2026 12:27:35 +0200 Message-ID: <2026050735-vantage-encircle-acad@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.6-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.6.y git checkout FETCH_HEAD git cherry-pick -x fad217e16fded7f3c09f8637b0f6a224d58b5f2e # git commit -s git send-email --to '' --in-reply-to '2026050735-vantage-encircle-acad@gregkh' --subject-prefix 'PATCH 6.6.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); }