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 8983632572C; Thu, 19 Feb 2026 20:49:58 +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=1771534198; cv=none; b=Z8xUEOPS14ZjAucfQNeg09toPxYGPCVkYY8iFJwVQ0ZvYD+9ci+bLAX7RnW121VdI8rywO6+fsJz4Tr/IZhwJsYICfKr6N7tsx1oOXQ+LarTJ44OJZt4el7kVMhbX5l/+6Ch7VbOc14t0CYDB1xjbXPpbQVFOGLu2HbhSV0Y5lE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771534198; c=relaxed/simple; bh=AO1s0ZwsAwaiASVhsmyjGkQ1JXVRT89ksdTYvzU7lAM=; h=Message-ID:Date:From:To:Cc:Subject:References:MIME-Version: Content-Type; b=ToiMw0kVhSTv2ZOf6xMk3mouNuVUurbYE7EUeVIQ1WinnLOvMYWnGsUu0JcKSstyZs+ccus7UyHBq27QKFtbWTDM5Xs2LaQsTGpUCF/q/ZFRuUl2Dvjvk2Zi8asGDUBLmeOcBPETNQiTceHa+KGcA21esunKfipXnQj5Vihm9SY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mYg63Xpf; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mYg63Xpf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 64A39C2BCB0; Thu, 19 Feb 2026 20:49:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771534198; bh=AO1s0ZwsAwaiASVhsmyjGkQ1JXVRT89ksdTYvzU7lAM=; h=Date:From:To:Cc:Subject:References:From; b=mYg63XpfZGfoa091lztuIrvyUJt0Jt663A/VqtQQ8E+uYo7r35rr12FJFnjj787hi 6lMlJs5oVgq+RNdftQRYGL/nIBM1reA3rWOKlhtsW7Nctq/0IawbwzbDbmfB4kLZLq /u0uBGR5c7k2MWxliGkATl5LlQOS2j1PEheH7Fgmx7jfwKOk/Gs6+2q3s1C5vz2X19 3LHWcn3J8mh46ui21/Be9Yjvn/GEcNjj5MNolxEDPaI4hz1y/ORY870yx8bWx6FSLK JCWaR70QtWIMttjK9wr+NCUkgK38ZnCRZwoeSBw6qcyt+ZNKyhRPZD1okAi+NulMmj 8dNyVpOZnzE+A== Received: from rostedt by gandalf with local (Exim 4.99.1) (envelope-from ) id 1vtAyL-00000000kgm-1Q3p; Thu, 19 Feb 2026 15:50:05 -0500 Message-ID: <20260219205005.194297642@kernel.org> User-Agent: quilt/0.69 Date: Thu, 19 Feb 2026 15:49:51 -0500 From: Steven Rostedt To: linux-kernel@vger.kernel.org Cc: Masami Hiramatsu , Mark Rutland , Mathieu Desnoyers , Andrew Morton , stable@vger.kernel.org, Tom Zanussi , Petr Pavlu Subject: [for-linus][PATCH 4/5] tracing: Fix checking of freed trace_event_file for hist files References: <20260219204947.830172370@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 From: Petr Pavlu The event_hist_open() and event_hist_poll() functions currently retrieve a trace_event_file pointer from a file struct by invoking event_file_data(), which simply returns file->f_inode->i_private. The functions then check if the pointer is NULL to determine whether the event is still valid. This approach is flawed because i_private is assigned when an eventfs inode is allocated and remains set throughout its lifetime. Instead, the code should call event_file_file(), which checks for EVENT_FILE_FL_FREED. Using the incorrect access function may result in the code potentially opening a hist file for an event that is being removed or becoming stuck while polling on this file. Correct the access method to event_file_file() in both functions. Cc: stable@vger.kernel.org Cc: Mathieu Desnoyers Cc: Tom Zanussi Link: https://patch.msgid.link/20260219162737.314231-2-petr.pavlu@suse.com Fixes: 1bd13edbbed6 ("tracing/hist: Add poll(POLLIN) support on hist file") Signed-off-by: Petr Pavlu Acked-by: Masami Hiramatsu (Google) Signed-off-by: Steven Rostedt (Google) --- kernel/trace/trace_events_hist.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c index e6f449f53afc..768df987419e 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -5784,7 +5784,7 @@ static __poll_t event_hist_poll(struct file *file, struct poll_table_struct *wai guard(mutex)(&event_mutex); - event_file = event_file_data(file); + event_file = event_file_file(file); if (!event_file) return EPOLLERR; @@ -5822,7 +5822,7 @@ static int event_hist_open(struct inode *inode, struct file *file) guard(mutex)(&event_mutex); - event_file = event_file_data(file); + event_file = event_file_file(file); if (!event_file) { ret = -ENODEV; goto err; -- 2.51.0