From nobody Mon Jun 15 20:32:15 2026 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E236A36165E for ; Mon, 13 Apr 2026 19:06:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776107169; cv=none; b=CBKZuLuYXUJBjF04Ra90lPgHgZonQp8RlN49wgwaoJUdpTJnmAh+HAaZTqXxUmxUESwT4jnVW5L3V4ow31JkNcX/uMlQK7wRKe2xbiHe3w/Lqe1eH230AsdKaiNylQBNn2uLMDQT/utmRg2gAAkyCD3ffpvemFzWV0anoVtv3Vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776107169; c=relaxed/simple; bh=DHvTbgVBW3hw/f0a//QlChJQ2MhY8ExqMLSzgMSMh1M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=rXt2tUkwhIoZCyQdhVTffT/mPPO5FVf2l9eHxmDdmYJ+p63rTgmUGI8vvkkmaSXjRKYmt7DWLJp/o5uVHLkaAVFKjy8/BoIS+cSx6BzTmiacBPPaY4IBsqDTlAzzbT12RHBbWSK8xgTH83YTMdjcAYE7oJmQozFAhkMKg+36z9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=PMjQYVoQ; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PMjQYVoQ" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso39483445e9.0 for ; Mon, 13 Apr 2026 12:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1776107165; x=1776711965; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=x+CMGgVpbGSFYrtIdzPvzmGJsZQ3Z4zuKxslghksSgw=; b=PMjQYVoQvJS0lEJXD+gduttFbpf9YGCLB+jqy9chm5CX0lbGKs79Vk67stAZlJ4ol1 72lv2NbplJWcHBWPX7OSQE4Jv+Hm8R92uWGg1e3bk3Q/gt19QIAg8fATCY/b6dgipneH Lki7TNIJhGNEHhzmdkVXnPS1jA5UKrfN1if9mwbQUCFnGG8/TP5n1i5+Nu/DfAtMEaz2 rPzTuS9uAZsIwOF4qIvxHTU9SxXmLwLt5pfnmBndokQy0hC+7wrgmkh3fsrc8mGklTX9 hqmdguNwWyzh+W+fLCbR4p/RGnkgI2iZyhU8V7NaCaR5kh3oeRS3yYBCJtEvsMfPJA8l iFxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776107165; x=1776711965; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x+CMGgVpbGSFYrtIdzPvzmGJsZQ3Z4zuKxslghksSgw=; b=EjrJq1FmQeo+1xgfMhEdZhGMTG5b/RvDUn0Pw66UrqsapQHb6NZpIxpxV7R2jF1tdY xnPxdmTEE1ZMti1nOJn8VtYy5GA+smpSHUbjf+wk0FSmpRO0DCYpDL++HwGbuNOT3obs +KW4mRMwHNiYH7RbCIy4+D/iG9hHy5Qon66EZPvS/VhKeBz3D972tveZ5wFCbk8i3w9/ i/maKUT3oUnmorMSv2g6uXWFeA9Jz/i3E/qFiDDlGSQsH4ewGQk5Kz/Y8I1l/Ifqk1+K iP2FWxVTO8hFRO0jasZOOBqfCvxoAR+NaB2Zbjjq9DBQRRl5N/x0dqJlfJJQHYtVWmkr 6IMA== X-Forwarded-Encrypted: i=1; AFNElJ+2JgdObYp7mUziz7y1gp3YEVaypAXNKVS7GXKjsgxPrHHsB0pjphaGl4MfOTmyBbtRlTCCCNa2YEuFDq8=@vger.kernel.org X-Gm-Message-State: AOJu0YwBjCHPbxVckadZlFup3vySyt+3awBUeIYEKfvA/dOUmOgj0OVK gJnX/CCny1BZgtT/ddinigOShBWlizduyv3/Zb8bZqhPdFhp7x35tDnIYOa/jdN22v8= X-Gm-Gg: AeBDietgUQszKE1OofcZ5BUTeTXrrQ9B1MZ9AwsG/qpePqrXAblI32ICNkybW2nlZQg ylskjQ+GXHqnq8qlndkI0QmsqrOrPzwb8wUqfyhyYSzZL8wguHQwPq7OOXPxvfX6lzLmMxEPqN8 1ib3WyFwaJi1RylucZGTGG2SDsWIUMEopCC1LTzmzXeuy37wE3GSLX5M+Tv39ODLl/ADZGJKQmc fhf4EuTj/+BB8oX6I0oy2y1u8gWZhxqbrnBuTCERq9o2wYf5EDD8TGDTlkOHUqIaeI5dID5M5Gr 7CbSebyaR/KXotitdDSThYMK6yW2nY7Em0ccH6Xox588SAtq7RMH3lflQY/qfTz7lwuxuIC8l9A s9w9nMXwtNDnVaDaaQgbejNNKGZeiSUuJBMw9ELsHteTovgtXdp8oKWFWpDBhF7o8BI3EOg6RtN JYfkv5YpWQmqGlSMlsr7vtXRYWU0KA2b+qeVAOjErEyJO7orWpm/pXmDCfv00e/551YawLfgdzF dezsCmjZVvC X-Received: by 2002:a05:600c:3b96:b0:488:b098:b653 with SMTP id 5b1f17b1804b1-488d67f0a8amr202216175e9.13.1776107165068; Mon, 13 Apr 2026 12:06:05 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-488d538c39bsm309952685e9.14.2026.04.13.12.06.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Apr 2026 12:06:03 -0700 (PDT) From: David Carlier To: Steven Rostedt , Masami Hiramatsu , Mathieu Desnoyers Cc: linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, David Carlier , stable@vger.kernel.org Subject: [PATCH] tracepoint: balance regfunc() on func_add() failure in tracepoint_add_func() Date: Mon, 13 Apr 2026 20:06:01 +0100 Message-ID: <20260413190601.21993-1-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Signed-off-by: David Carlier --- kernel/tracepoint.c | 2 ++ 1 file changed, 2 insertions(+) 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 =3D 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) !=3D -ENOMEM); return PTR_ERR(old); } --=20 2.53.0