From nobody Thu Apr 2 15:38:03 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (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 37A6331AF25 for ; Tue, 10 Feb 2026 11:34:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770723292; cv=none; b=T7vL3XG0VPrDd2/9cxiarrglBEoyTnDSoZtHbO+hc8OvdcbJGpgMebeAn3AXmqE6Zy7o6GjyCUPN//MPIWLuOaFfqnL6VRsiipgN9YXY3ioAz+BraKGf3G6A0szk8PMKRsTvNigcPKDNDeQ8kaXoMPY7IzxyJrNpJxkaTJgNAdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770723292; c=relaxed/simple; bh=0xU71SkOti3kTgJYWms4PrdcUYZl6h4meNUN5JHsWe8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eTFPmfeHyhUdyTjczE8rpj1qSTcdL8tSLHh4i3LaEFr3N8xojlWZNvuMhmLCmNf7yDteeNibJttoplHgGBkm1fxqUr4cSzCjkLNqLXJadrGG7Yecq096kPAI9yes6C0OTer8khMScdrgAWlkoeTyLZDnEu5PJLtdhkm/ltnkw3k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=J/dVBla3; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="J/dVBla3" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-47edd6111b4so80403205e9.1 for ; Tue, 10 Feb 2026 03:34:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1770723290; x=1771328090; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+gbx0AbZEG5vm2vG4RENDj7vKJAZc/9+lYAtjtBx+1U=; b=J/dVBla3KNoFYhtkD8i84c5gP6OtQ4Qxfpc34jHQmWRcnP/2xDBM/p4C8TiKujKC3v 8qv5AEhyV99IAdZ60NuRyASzUCj4hXYqfV9XChjwHYJVeN2EkPjtlVPdvrs65RcknSs0 LD58ocEMgT30rKxnXmT68XLtJEmZzh4+G5PjEjStWPhbnjB7bVdLCmgiJ5A6LR9EAP8o hVRd+8pBy/2OcEPECB1bih583Mhxfj7V1ijZ0iu2nFiEiI5TJuGe2s0aKzksXVqzOfix Fqw9lhJb3Sd9lXjRFZySjJ5x6w4iB9KUSHfMRSbpTJirna0B60P+bsiWyr9iAQCqFj+F m59w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770723290; x=1771328090; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+gbx0AbZEG5vm2vG4RENDj7vKJAZc/9+lYAtjtBx+1U=; b=laZCWchvMzZVdL1JbBUyxhVR8fYB9BLiy1RY9eDbJTtBbqmnpx0TKa9zrPk3effsC6 40BCEyUQQ/gKCgbT0qgFie3bL1PN/rkO6BBZWQHagot7bznfNWrma6QAhVTJFrnZYGIK 3Nb+kK5wImYqOTkjAT0ri1jZaZ8WSTt7qNftUr/UVhj1vCmFrunnhpnz/KqKpEuug5j8 LFaoZbuVU3XkhHw3OZWyHiWrdEVe1D0WiB2xGmXzSDrAkroOYQQxTmnXwZp7n4Jobcko UvAlu+xmjXcApObqJIczHr7aNg4pd4MNqhmOElTQpSmVJCkd+Rfws3dPf9p4oiH9Zjp2 cXSA== X-Forwarded-Encrypted: i=1; AJvYcCVmdIWdWNjFcffAYkRjWkIaEzFxDcQxV9QuJptTTB+66+080tW0wqSfooyfJw/qMJQYCLmH9QrPje8tlEA=@vger.kernel.org X-Gm-Message-State: AOJu0Yz+Q7oSX52RsZm0WCd/MQXpAeg4Xi1eVw+tFbRwUNIzDGGUDVcO sqRdJzllQkoCAIZrD6pLXhfI4bdiPwWZHFYUY4gsT7pkS3q0hpMmTlCAL8zKSvl/u8o= X-Gm-Gg: AZuq6aKuUFBFwFnliNxA4L5pY++ORWMH6iUxa/IdXx/hpHbVf6qntcXnLFOP8TQDIom imvVyXzUOMl5Ycns4qlDSI7/xAzD7HHwuWfDB+hVJu55u/AhKVmGa3qgSCPSocu1LxmibReTngC Iaqk8Uoqvc4qyU7RoKTqKdFelACAEohyxkZUuik6sQhMrk0EwgC4bxQwDgxwy2nDFqdnPpR3VqY OJSH760cmYTAXHtsgMmQAXm4QElV3637DIvBh7r9syyCVqHhkVnoc1IEpzY41KPvNYK18fZiLTN /EdQVbWnk2LD6ycFp715CLhEZmeS76E3NSYInw8TfWvVkwTtNnlAziYMgYninYRxgMmr4AykCyd Bsv+6w5mvHVdh4iyOSyMIiJvybAE3BkAO0+Q9qG+pnXv0Pkbw2WqPiSIPSCXBgq1sOEFROjtdB/ CqWLTRwRFyXKIerNkpYgUDR3IEfTgS7WIg2Gd4SmY+APyKagte7ehRs08F7Ko8spJloqmHrc5x8 3GsLx92ZLKfi8aR70rhAPaO X-Received: by 2002:a05:600c:c16b:b0:480:20f1:7abd with SMTP id 5b1f17b1804b1-4835082d1a3mr26387265e9.31.1770723289691; Tue, 10 Feb 2026 03:34:49 -0800 (PST) Received: from zovi.suse.cz (dynamic-2a00-1028-838d-271e-8e3b-4aff-fe4c-a100.ipv6.o2.cz. [2a00:1028:838d:271e:8e3b:4aff:fe4c:a100]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-483209cfd77sm120182275e9.14.2026.02.10.03.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 03:34:49 -0800 (PST) From: Petr Pavlu To: Steven Rostedt , Masami Hiramatsu Cc: Mathieu Desnoyers , Tom Zanussi , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, Petr Pavlu Subject: [PATCH 2/5] tracing: Fix checking of freed trace_event_file for id files Date: Tue, 10 Feb 2026 12:28:17 +0100 Message-ID: <20260210113427.1068932-3-petr.pavlu@suse.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260210113427.1068932-1-petr.pavlu@suse.com> References: <20260210113427.1068932-1-petr.pavlu@suse.com> 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" The code for reading an event id currently uses file->f_inode->i_private to store the value of trace_event_file->event_call->event.type, unlike all other event files which use it to store a pointer to the associated trace_event_file data. The event_id_read() function retrieves this id value from i_private and checks if it is non-0/NULL to determine whether the event is still valid. This approach worked in the past when remove_event_file_dir() would set i_private to NULL for all files in an event directory upon removal. However, with the introduction of eventfs, i_private is assigned when an eventfs inode is allocated and remains set throughout its lifetime. As a result, event_id_read() may fail to detect that an event is being removed. Fix this issue by changing the event id file to use i_private to store a trace_event_file pointer and utilize event_file_file() to check for the EVENT_FILE_FL_FREED flag. Fixes: 6fdac58c560e ("tracing: Remove unused trace_event_file dir field") Signed-off-by: Petr Pavlu --- kernel/trace/trace_events.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index e8ed6ba155cf..3d272b3cd688 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c @@ -2090,11 +2090,18 @@ static int trace_format_open(struct inode *inode, s= truct file *file) static ssize_t event_id_read(struct file *filp, char __user *ubuf, size_t cnt, loff_t *pp= os) { - int id =3D (long)event_file_data(filp); + struct trace_event_file *file; + int id; char buf[32]; int len; =20 - if (unlikely(!id)) + mutex_lock(&event_mutex); + file =3D event_file_file(filp); + if (likely(file)) + id =3D file->event_call->event.type; + mutex_unlock(&event_mutex); + + if (!file) return -ENODEV; =20 len =3D sprintf(buf, "%d\n", id); @@ -2572,7 +2579,9 @@ static const struct file_operations ftrace_event_form= at_fops =3D { =20 #ifdef CONFIG_PERF_EVENTS static const struct file_operations ftrace_event_id_fops =3D { + .open =3D tracing_open_file_tr, .read =3D event_id_read, + .release =3D tracing_release_file_tr, .llseek =3D default_llseek, }; #endif @@ -2936,7 +2945,6 @@ static int event_callback(const char *name, umode_t *= mode, void **data, if (call->event.type && call->class->reg && strcmp(name, "id") =3D=3D 0) { *mode =3D TRACE_MODE_READ; - *data =3D (void *)(long)call->event.type; *fops =3D &ftrace_event_id_fops; return 1; } --=20 2.52.0