* [Devel] [PATCH hci-8.1 1/2] ms/eventfs: Use list_add_tail_rcu() for SRCU-protected children list
2026-11-16 14:40 [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes Eva Kurchatova
@ 2026-11-16 14:40 ` Eva Kurchatova
2026-11-16 14:45 ` no-reply
2026-11-16 14:40 ` [Devel] [PATCH hci-8.1 2/2] ms/eventfs: Free the eventfs_inode after an rcu grace period too Eva Kurchatova
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Eva Kurchatova @ 2026-11-16 14:40 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: David Carlier <devnexen@gmail.com>
[ Upstream commit f67950b2887fa10df50c4317a1fe98a65bc6875b ]
Commit d2603279c7d6 ("eventfs: Use list_del_rcu() for SRCU protected
list variable") converted the removal side to pair with the
list_for_each_entry_srcu() walker in eventfs_iterate(). The insertion
in eventfs_create_dir() was left as a plain list_add_tail(), which on
weakly-ordered architectures can expose a new entry to the SRCU reader
before its list pointers and fields are observable.
Use list_add_tail_rcu() so the publication pairs with the existing
list_del_rcu() and list_for_each_entry_srcu().
Fixes: 43aa6f97c2d0 ("eventfs: Get rid of dentry pointers without refcounts")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260418152251.199343-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
[ adapted scoped_guard(mutex, &eventfs_mutex) block to explicit mutex_lock()/mutex_unlock() pair ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 1801ce6ce6f9f1df134987e6bc47d28c1ebe9a51)
https://virtuozzo.atlassian.net/browse/VSTOR-154848
Feature: fix ms/tracefs
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
fs/tracefs/event_inode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index ca6e0a653efa..b1ad4f482f34 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -758,7 +758,7 @@ struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode
mutex_lock(&eventfs_mutex);
if (!parent->is_freed)
- list_add_tail(&ei->list, &parent->children);
+ list_add_tail_rcu(&ei->list, &parent->children);
mutex_unlock(&eventfs_mutex);
/* Was the parent freed? */
--
2.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread* [Devel] [PATCH hci-8.1 2/2] ms/eventfs: Free the eventfs_inode after an rcu grace period too
2026-11-16 14:40 [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes Eva Kurchatova
2026-11-16 14:40 ` [Devel] [PATCH hci-8.1 1/2] ms/eventfs: Use list_add_tail_rcu() for SRCU-protected children list Eva Kurchatova
@ 2026-11-16 14:40 ` Eva Kurchatova
2026-11-16 14:45 ` no-reply
2026-11-16 17:02 ` [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes Konstantin Khorenko
2026-11-16 17:02 ` Konstantin Khorenko
3 siblings, 1 reply; 7+ messages in thread
From: Eva Kurchatova @ 2026-11-16 14:40 UTC (permalink / raw)
To: khorenko; +Cc: devel
From: Christian Brauner <brauner@kernel.org>
commit 2cd88c498ecff8e22bf4c397b8eb226db70ac343 upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dd2c767814a876be0f16f0b7f98a403dc176f51e)
https://virtuozzo.atlassian.net/browse/VSTOR-154849
Feature: fix ms/tracefs
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
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 b1ad4f482f34..357663cfd4ba 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.56.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes
2026-11-16 14:40 [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes Eva Kurchatova
2026-11-16 14:40 ` [Devel] [PATCH hci-8.1 1/2] ms/eventfs: Use list_add_tail_rcu() for SRCU-protected children list Eva Kurchatova
2026-11-16 14:40 ` [Devel] [PATCH hci-8.1 2/2] ms/eventfs: Free the eventfs_inode after an rcu grace period too Eva Kurchatova
@ 2026-11-16 17:02 ` Konstantin Khorenko
2026-11-16 17:02 ` Konstantin Khorenko
3 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 17:02 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
Applying as is.
On Mon, 16 Nov 2026 16:40:22 +0200, Eva Kurchatova <eva.kurchatova@virtuozzo.com> wrote:
> Christian Brauner (1):
> ms/eventfs: Free the eventfs_inode after an rcu grace period too
>
> David Carlier (1):
> ms/eventfs: Use list_add_tail_rcu() for SRCU-protected children list
Separate patches, not needed for this series. I created a task for
each:
1. fs/tracefs/ still lacks two 6.12-stable fixes: 14f7f52629d91
("tracefs: Fix default permissions not being applied on initial
mount"), which leaves the tracefs root at 0755 instead of 0700, and
3bcb274a192fc ("tracefs: fix a leak in eventfs_create_events_dir()"),
which leaves the parent locked under LOCKDOWN_TRACEFS.
https://virtuozzo.atlassian.net/browse/VSTOR-155413
2. The mainline series of the eventfs fix in 2/2 also fixed ext4
(c17b44266a1f, "ext4: free the sbi after a grace period") and
unicode (a96c5299bd73, "unicode: free the map after a grace
period"): the same use-after-free from an RCU pathwalk racing with
the last unmount. 6.12-stable has both, we have neither.
https://virtuozzo.atlassian.net/browse/VSTOR-155414
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes
2026-11-16 14:40 [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes Eva Kurchatova
` (2 preceding siblings ...)
2026-11-16 17:02 ` [Devel] [PATCH hci-8.1 0/2] ms/eventfs: RCU handling fixes Konstantin Khorenko
@ 2026-11-16 17:02 ` Konstantin Khorenko
3 siblings, 0 replies; 7+ messages in thread
From: Konstantin Khorenko @ 2026-11-16 17:02 UTC (permalink / raw)
To: Eva Kurchatova; +Cc: devel
On Mon, 16 Nov 2026 16:40:22 +0200, Eva Kurchatova wrote:
> ms/eventfs: RCU handling fixes
>
> Patchset for tasks:
> - https://virtuozzo.atlassian.net/browse/VSTOR-154849
> - https://virtuozzo.atlassian.net/browse/VSTOR-154848
>
> Rebased backports from mainline only.
>
> [...]
Applied to branch-rh10-6.12.0-211.75.1.26.x.vz10-ovz, will be released in rh10-6.12.0-211.75.1.24.3.vz10, thanks!
[1/2] ms/eventfs: Use list_add_tail_rcu() for SRCU-protected children list
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/6e3daa6c0201
[2/2] ms/eventfs: Free the eventfs_inode after an rcu grace period too
https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/18bd29edd62f
--
Konstantin Khorenko,
Virtuozzo Linux Kernel Team
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
^ permalink raw reply [flat|nested] 7+ messages in thread