mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@kernel.org>
To: linux-kernel@vger.kernel.org
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org,
	"Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [for-linus][PATCH 13/16] eventfs: Free the eventfs_inode after an rcu grace period too
Date: Thu, 15 Oct 2026 09:33:23 -0400	[thread overview]
Message-ID: <20261015133404.546835597@kernel.org> (raw)
In-Reply-To: <20261015133310.731003448@kernel.org>

From: Christian Brauner <brauner@kernel.org>

tracefs_d_revalidate() reads ->is_freed of the eventfs_inode that
dentry->d_fsdata points to, and ->d_revalidate() is called in rcu
pathwalk mode with nothing but rcu_read_lock() held. The dentry itself
stays around for such a walker, but tracefs_d_release() drops its
reference to the eventfs_inode when the dentry is killed, and
release_ei() then frees it after a grace period of eventfs_srcu. An
SRCU grace period doesn't wait for rcu_read_lock() sections, so the
walker can read an eventfs_inode that is already gone.

With a pathwalk held up in tracefs_d_revalidate() while the dentry goes
away:

  BUG: KASAN: slab-use-after-free in tracefs_d_revalidate+0x76/0x90
  Read of size 1 at addr ff1100010152d8d0 by task walker/97
  Call Trace:
   <TASK>
   tracefs_d_revalidate+0x76/0x90
   lookup_fast+0x320/0x640
   path_lookupat+0x160/0xb00
   filename_lookup+0x1f1/0x5b0
   vfs_statx+0xd7/0x3b0
   vfs_fstatat+0x4d/0x90
   __do_sys_newfstatat+0xa0/0x100
   do_syscall_64+0x10e/0x5e0
   entry_SYSCALL_64_after_hwframe+0x77/0x7f
  [...]
  Allocated by task 1:
   __kmalloc_cache_noprof+0x249/0x560
   eventfs_create_dir+0x7a/0x590
   event_create_dir+0x2fb/0xcf0
   trace_add_event_call+0xbf/0x150
  [...]
  Freed by task 11:
   kfree+0x1db/0x5b0
   srcu_invoke_callbacks+0x3a3/0x620
   process_one_work+0x937/0x1810
   worker_thread+0x4f1/0xd60

Before commit 8e556432477e ("eventfs: Use SRCU for freeing
eventfs_inodes") release_ei() used call_rcu(), which covered the walker,
while eventfs_iterate() needs the SRCU grace period. Wait for both and
chain call_rcu() from the SRCU callback.

Cc: stable@vger.kernel.org
Fixes: 8e556432477e ("eventfs: Use SRCU for freeing eventfs_inodes")
Link: https://patch.msgid.link/20261009-work-fixes-rcu-v1-4-7446d2d335e6@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 fs/tracefs/event_inode.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 6e3513b13cfa..090aca946717 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -91,6 +91,14 @@ static void free_ei_rcu(struct rcu_head *rcu)
 	}
 }
 
+/* read under eventfs_srcu and, by tracefs_d_revalidate(), in rcu pathwalk */
+static void free_ei_srcu(struct rcu_head *rcu)
+{
+	struct eventfs_inode *ei = container_of(rcu, struct eventfs_inode, rcu);
+
+	call_rcu(&ei->rcu, free_ei_rcu);
+}
+
 /*
  * eventfs_inode reference count management.
  *
@@ -112,7 +120,7 @@ static void release_ei(struct kref *ref)
 			entry->release(entry->name, ei->data);
 	}
 
-	call_srcu(&eventfs_srcu, &ei->rcu, free_ei_rcu);
+	call_srcu(&eventfs_srcu, &ei->rcu, free_ei_srcu);
 }
 
 static inline void put_ei(struct eventfs_inode *ei)
-- 
2.53.0

  parent reply	other threads:[~2026-10-15 13:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 13:33 [for-linus][PATCH 00/16] tracing: Fixes for v7.3 Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 01/16] tracing: Fix NULL dereference when copying keys for a field variable Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 02/16] tracing: Take trace_types_lock when dropping the buffer_meta reference Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 03/16] ring-buffer: Do not show buffer_meta for CPUs without a buffer Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 04/16] tracing: Fix the shift out of bounds in the log2 histogram modifier Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 05/16] ring-buffer: Fix the sub-buffer array base in rb_meta_subbuf_idx() Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 06/16] tracing: Fix empty symbol names in simple_ring_buffer undef check Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 07/16] tracing: Fix simple_ring_buffer undef check on parisc Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 08/16] tracing: Fix simple_ring_buffer undef check on sparc64 Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 09/16] ring-buffer: Fix false warning in ring_buffer_map_get_reader() Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 10/16] tracing: Fix ignored return value of resize_buffer_duplicate_size() Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 11/16] tracing: Fix hist trigger timestamps for buffered events Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 12/16] tracing: Do not initialize tracefs work if tracing is disabled Steven Rostedt
2026-10-15 13:33 ` Steven Rostedt [this message]
2026-10-15 13:33 ` [for-linus][PATCH 14/16] ring-buffer: Skip si_mem_available() for persistent and remote buffers Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 15/16] ring-buffer: Use subbuf_order in available memory estimation Steven Rostedt
2026-10-15 13:33 ` [for-linus][PATCH 16/16] tracing/histograms: Reject non-stacktrace fields for synthetic stacktrace fields Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261015133404.546835597@kernel.org \
    --to=rostedt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=brauner@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®