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=1796381356; b=wrWO41gf03UZYDwMg4jIY6ZoukDGr31BmGhkNF6RDte3w3dYA1JabzewC6KuPwYM+Vs7 NruwmH5xJEI9NQMPFDTjeO1dByz3mmIzj8id5Ubvneh8Rl6VDVFj/aJl1MMT12IwbScVp kKq2g8O5/vA2DJAWSJqsMua4NKElFBwAqvvTG5udyP+zmoKeAQLW74gaPJRbfjR+rcosQ rbepShOOHVoq09wHwCUpW/rT315VoL7421ND+NzOnKYjeyJQPrGWoMHgHfxcTOQgisR8b +4UPnQn9f1eHgjYY4LLUEgEORIwsGW+sJN4JNWuieRSONRGy6/F9ooRUQTuFNY9RX8Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381356; 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=T+Uxj/DkZL9Wkw1bso/eFE267Cfq7bhrCn1b2aNcCso=; b=k3BLJmY6jtxCHQEBbNbEAwOKphf4muv3PF2awTQEtE8QmOymA0v4l0cDryVZogUjQJZL SpN4R2SEaqW7LGjL0r/l1NoC1IpjR5BaW544g+Ybpp9rFC4Kl0zFUhzANNuNKmaCjW3Ry UHxjvnGdIdW/PfYLH2lhdo9CpVHY1vuzYkgioAeSl5lKHR3rdt5GpxGLB+tgK+6qCr24Z g2+f7KQFZCzscmtZo7fF3AiEkEVm4kdW7YS+vCAkJQPN9oQ/LhT9Qz6O6MFhMsXWJblKv TxxY6PYL4ML2sC5W4OQnUjs38N0EZ8WPkiNInXfB0ksaYfZIIVuyW4oTDkNGRU7k0ZQ== 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=TOSbTpxC; 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 34BA2606A335; Fri, 4 Dec 2026 10:49:16 +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=TOSbTpxC Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5AEB1F000CE; Fri, 4 Dec 2026 10:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381356; bh=T+Uxj/DkZL9Wkw1bso/eFE267Cfq7bhrCn1b2aNcCso=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TOSbTpxC8d9FnP4lhCyrwDu5FvlAxBZbYVgWRrRghgPi4wtAVvnATrqqhgPmspe8P 0diZ5vXgQttFEQShVmXBKl9JZPoHqXbuQ5tH2SVBZOvxswU3bgjC/x5djspY7CYyYv aaXzAK/m8WQr2uZ1LOR9EQ1P0quFi++ANUhMH5gY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Carlier , Steven Rostedt Subject: [PATCH 7.3 669/742] tracing/user_events: Dont free an event that a dynamic event still references Date: Fri, 4 Dec 2026 19:08:53 +0900 Message-ID: <20261204100652.841258324@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Carlier commit 0fbdc293697a5d72dc985e533eef5155a1b264cc upstream. An eprobe takes a reference on the call of the event it attaches to, and kprobe, uprobe, fprobe and synth events all refuse to go away while trace_event_dyn_busy() says such a reference exists. user_events never checks it, so a user event can be freed under an eprobe: echo 'u:test u32 a' >> dynamic_events echo 'e:ep user_events/test a=$a' >> dynamic_events echo '-:user_events/test u32 a' >> dynamic_events echo '-:eprobes/ep' >> dynamic_events The last write drops the reference on the freed call. If the last fd of a non-persistent event closes while such a reference is held, the delayed destroy now fails. Mark the event persistent then, so it can still be deleted once the reference is gone instead of being leaked. Return -EBUSY from destroy_user_event() in that case. Fixes: 7f5a08c79df3 ("user_events: Add minimal support for trace_event into ftrace") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20261031212453.16116-1-devnexen@gmail.com Signed-off-by: David Carlier Signed-off-by: Steven Rostedt Signed-off-by: Greg Kroah-Hartman --- kernel/trace/trace_events_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/kernel/trace/trace_events_user.c +++ b/kernel/trace/trace_events_user.c @@ -256,6 +256,11 @@ static void delayed_destroy_user_event(s * attempt to delete it later. */ pr_warn("user_events: Unable to delete event\n"); + /* + * Keep it as persistent so it can be still deleted + * since nobody own this event + */ + user->reg_flags |= USER_EVENT_REG_PERSIST; refcount_set(&user->refcnt, 1); } out: @@ -1506,6 +1511,10 @@ static int destroy_user_event(struct use lockdep_assert_held(&event_mutex); + /* If there is a reference to a dynamic event */ + if (trace_event_dyn_busy(&user->call)) + return -EBUSY; + /* * Detach the fields before removing the call. Removing the event * frees the field list memory (trace_destroy_fields() is run on