All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 0/4] ms/eventfs: fix kernel panic on NULL dereference
@ 2026-11-11 20:34 Eva Kurchatova
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-11 20:34 UTC (permalink / raw)
  To: khorenko; +Cc: devel

Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-154529

Note: The last two patches are cherry-picks from 6.12.y stable tree
backport, as the code differs in the mainline.

Deepanshu Kartikey (1):
  ms/eventfs: Initialize ei->children and ei->list in init_ei()

Joseph Qi (1):
  ms/eventfs: fix SRCU read lock leak in eventfs_iterate()

Shuangpeng Bai (1):
  ms/eventfs: Fix use-after-free in eventfs_remove_rec()

Steven Rostedt (1):
  ms/eventfs: Use children field for rcu head and add memory barriers

 fs/tracefs/event_inode.c | 37 ++++++++++++++++++++++++++++++-------
 fs/tracefs/internal.h    |  4 ++--
 2 files changed, 32 insertions(+), 9 deletions(-)

-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec()
  2026-11-11 20:34 [Devel] [PATCH hci-8.1 0/4] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
@ 2026-11-11 20:34 ` Eva Kurchatova
  2026-11-11 20:39   ` no-reply
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 2/4] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-11 20:34 UTC (permalink / raw)
  To: khorenko; +Cc: devel

From: Shuangpeng Bai <shuangpeng.kernel@gmail.com>

eventfs_remove_rec() recursively removes the child at the current loop
position. After the recursive call returns, list_for_each_entry() advances
by reading list.next from the removed child.

If free_ei() drops the final reference, release_ei() reuses the list/rcu
union to queue an SRCU callback. The child may be freed before that read.
The eventfs_mutex serializes list updates, but it does not keep the removed
child alive or prevent the SRCU callback from running.

Use list_for_each_entry_safe() to save the next sibling before recursively
removing the current child.

Cc: stable@vger.kernel.org
Fixes: 43aa6f97c2d0 ("eventfs: Get rid of dentry pointers without refcounts")
Link: https://patch.msgid.link/20260806022719.375354-1-shuangpeng.kernel@gmail.com
Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
(cherry picked from commit fd73b691702170d37d66f4b0278530cea8ed419a)

https://virtuozzo.atlassian.net/browse/VSTOR-154529
Feature: fix ms/tracefs

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 fs/tracefs/event_inode.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index ce61795a7ed5..cc08218d6e26 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -848,7 +848,7 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
  */
 static void eventfs_remove_rec(struct eventfs_inode *ei, int level)
 {
-	struct eventfs_inode *ei_child;
+	struct eventfs_inode *ei_child, *tmp;
 
 	/*
 	 * Check recursion depth. It should never be greater than 3:
@@ -861,7 +861,7 @@ static void eventfs_remove_rec(struct eventfs_inode *ei, int level)
 		return;
 
 	/* search for nested folders or files */
-	list_for_each_entry(ei_child, &ei->children, list)
+	list_for_each_entry_safe(ei_child, tmp, &ei->children, list)
 		eventfs_remove_rec(ei_child, level + 1);
 
 	list_del_rcu(&ei->list);
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Devel] [PATCH hci-8.1 2/4] ms/eventfs: Use children field for rcu head and add memory barriers
  2026-11-11 20:34 [Devel] [PATCH hci-8.1 0/4] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
@ 2026-11-11 20:34 ` Eva Kurchatova
  2026-11-11 20:40   ` no-reply
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 4/4] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
  3 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-11 20:34 UTC (permalink / raw)
  To: khorenko; +Cc: devel

From: Steven Rostedt <rostedt@goodmis.org>

[ Upstream commit f0ece16ffca7384787b692431961ce202907acf5 ]

When an eventfs inode is freed, it sets ei->is_freed and then uses its
ei->list to add it to the srcu link list as the list field is a union with
the rcu list head. As the ei->list is used to iterate over an SRCU
protected list without taking the eventfs_mutex, there's nothing stopping
the iteration over that list to see the ei->rcu instead of the ei->list
and it will read a corrupt target.

To fix this, change the union of the rcu list head with the children list.
On freeing the eventfs inode, set the is_free and execute a smp_wmb()
before adding the eventfs inode to the SRCU list.

On iteration of the ei->children list, at the start, execute a smp_rmb()
and then read the is_freed of the ei to see if the children list is still
valid. If is_freed is set, then the ei_child read is not valid and the
loop should exit immediately.

Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260808094215.4252430d@robin
Fixes: 704f960dbee2f ("eventfs: Read ei->entries before ei->children in eventfs_iterate()")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Closes: https://sashiko.dev/#/patchset/20260806022719.375354-1-shuangpeng.kernel%40gmail.com
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 1b95382da85cff3bf0f922ff0275f186abdadfce)

https://virtuozzo.atlassian.net/browse/VSTOR-154529
Feature: fix ms/tracefs

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 fs/tracefs/event_inode.c | 24 ++++++++++++++++++++++++
 fs/tracefs/internal.h    |  4 ++--
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index cc08218d6e26..a157b4cf2b30 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -124,7 +124,17 @@ static inline void put_ei(struct eventfs_inode *ei)
 static inline void free_ei(struct eventfs_inode *ei)
 {
 	if (ei) {
+		/* The ei should have no children if it is being freed. */
+		WARN_ON_ONCE(!list_empty(&ei->children));
 		ei->is_freed = 1;
+		/*
+		 * The SRCU iteration has a smp_rmb() to make sure it
+		 * sees a child (that may have already been freed)
+		 * before it reads is_free. If is_free is set, it must
+		 * not use the child it acquired from ei->children, as
+		 * the list may be used for SRCU.
+		 */
+		smp_wmb();
 		put_ei(ei);
 	}
 }
@@ -647,6 +657,20 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx)
 	list_for_each_entry_srcu(ei_child, &ei->children, list,
 				 srcu_read_lock_held(&eventfs_srcu)) {
 
+		/*
+		 * If the ei is being freed, then the ei->children may be
+		 * being used as the rcu list, which means the next element
+		 * may be garbage. The ei->is_free is set before switching
+		 * the ei->children over to ei->rcu. The read memory barrier
+		 * here makes sure the ei_child is read before is_free is
+		 * updated.
+		 *
+		 * Matches the smp_wmb() in free_ei()
+		 */
+		smp_rmb();
+		if (ei->is_freed)
+			return -EINVAL;
+
 		if (c > 0) {
 			c--;
 			continue;
diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h
index a4a7f8431aff..c61481d04c8e 100644
--- a/fs/tracefs/internal.h
+++ b/fs/tracefs/internal.h
@@ -46,11 +46,11 @@ struct eventfs_attr {
  * @ino:	The saved inode number
  */
 struct eventfs_inode {
+	struct list_head	list;
 	union {
-		struct list_head	list;
+		struct list_head	children;
 		struct rcu_head		rcu;
 	};
-	struct list_head		children;
 	const struct eventfs_entry	*entries;
 	const char			*name;
 	struct eventfs_attr		*entry_attrs;
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
  2026-11-11 20:34 [Devel] [PATCH hci-8.1 0/4] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 2/4] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
@ 2026-11-11 20:34 ` Eva Kurchatova
  2026-11-11 20:39   ` no-reply
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 4/4] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
  3 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-11 20:34 UTC (permalink / raw)
  To: khorenko; +Cc: devel

From: Joseph Qi <joseph.qi@linux.alibaba.com>

Commit 1b95382da85c ("eventfs: Use children field for rcu head and add
memory barriers") added an early bail out to the ei->children loop:

	smp_rmb();
	if (ei->is_freed)
		return -EINVAL;

Upstream wraps eventfs_iterate() in guard(srcu)(&eventfs_srcu), so that
return still drops the read lock. The 6.12.y backport instead brackets the
function with srcu_read_lock() and a shared "out" label that calls
srcu_read_unlock(), so this path returns while still holding eventfs_srcu
for reading.

The unbalanced reader prevents the grace period from ever completing, so
the call_srcu() callback queued by free_ei() never runs and the
eventfs_inode is leaked. Every readdir that races with removal adds
another reader.

Set ret and jump to "out" like the other bail out paths in this function
do.

Fixes: 1b95382da85c ("eventfs: Use children field for rcu head and add memory barriers")
Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 9e899910695944c4ffbcdc6eac65be6485b146b4)

https://virtuozzo.atlassian.net/browse/VSTOR-154529
Feature: fix ms/tracefs

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 fs/tracefs/event_inode.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index a157b4cf2b30..fbaa64e482e0 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -668,8 +668,10 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx)
 		 * Matches the smp_wmb() in free_ei()
 		 */
 		smp_rmb();
-		if (ei->is_freed)
-			return -EINVAL;
+		if (ei->is_freed) {
+			ret = -EINVAL;
+			goto out;
+		}
 
 		if (c > 0) {
 			c--;
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Devel] [PATCH hci-8.1 4/4] ms/eventfs: Initialize ei->children and ei->list in init_ei()
  2026-11-11 20:34 [Devel] [PATCH hci-8.1 0/4] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
                   ` (2 preceding siblings ...)
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
@ 2026-11-11 20:34 ` Eva Kurchatova
  2026-11-11 20:40   ` no-reply
  3 siblings, 1 reply; 9+ messages in thread
From: Eva Kurchatova @ 2026-11-11 20:34 UTC (permalink / raw)
  To: khorenko; +Cc: devel

From: Deepanshu Kartikey <kartikey406@gmail.com>

eventfs_create_dir() allocates the eventfs_inode and initializes it with
init_ei(). But this does not initialize the eventfs_inode list_heads. If
the eventfs_create_dir() fails due to memory pressure, it will call
free_ei() before it initialized the lists, and that checks to make sure
the eventfs_inode has no children. But because the list wasn't
initialized, it will give a false warning.

Fix it by moving the list initialization into init_ei().

Cc: stable@vger.kernel.org
Fixes: 5790b1fb3d67 ("eventfs: Remove eventfs_file and just use eventfs_inode")
Reported-by: syzbot+3ef80b4ed02226d04a06@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=3ef80b4ed02226d04a06
Link: https://patch.msgid.link/20260824144653.54044-1-kartikey406@gmail.com
Signed-off-by: Deepanshu Kartikey <kartikey406@gmail.com>
[ Rewrote change log ]
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
(cherry picked from commit 1704aaaf5d22bc765c168402350d191e24e245bc)

https://virtuozzo.atlassian.net/browse/VSTOR-154529
Feature: fix ms/tracefs

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 fs/tracefs/event_inode.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index fbaa64e482e0..ca6e0a653efa 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -446,6 +446,8 @@ static inline struct eventfs_inode *init_ei(struct eventfs_inode *ei, const char
 	if (!ei->name)
 		return NULL;
 	kref_init(&ei->kref);
+	INIT_LIST_HEAD(&ei->children);
+	INIT_LIST_HEAD(&ei->list);
 	return ei;
 }
 
@@ -753,8 +755,6 @@ struct eventfs_inode *eventfs_create_dir(const char *name, struct eventfs_inode
 	ei->entries = entries;
 	ei->nr_entries = size;
 	ei->data = data;
-	INIT_LIST_HEAD(&ei->children);
-	INIT_LIST_HEAD(&ei->list);
 
 	mutex_lock(&eventfs_mutex);
 	if (!parent->is_freed)
@@ -826,9 +826,6 @@ struct eventfs_inode *eventfs_create_events_dir(const char *name, struct dentry
 	ei->attr.uid = uid;
 	ei->attr.gid = gid;
 
-	INIT_LIST_HEAD(&ei->children);
-	INIT_LIST_HEAD(&ei->list);
-
 	ti = get_tracefs(inode);
 	ti->flags |= TRACEFS_EVENT_INODE;
 	ti->private = ei;
-- 
2.56.0

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec()
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
@ 2026-11-11 20:39   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-11 20:39 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko; +Cc: devel

> From: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
> 
> eventfs_remove_rec() recursively removes the child at the current loop
> position. After the recursive call returns, list_for_each_entry() advances
> by reading list.next from the removed child.
> 
> If free_ei() drops the final reference, release_ei() reuses the list/rcu
> union to queue an SRCU callback. The child may be freed before that read.
> The eventfs_mutex serializes list updates, but it does not keep the removed
> child alive or prevent the SRCU callback from running.
> 
> Use list_for_each_entry_safe() to save the next sibling before recursively
> removing the current child.
> 
> Cc: stable@vger.kernel.org
> Fixes: 43aa6f97c2d0 ("eventfs: Get rid of dentry pointers without refcounts")
> Link: https://patch.msgid.link/20260806022719.375354-1-shuangpeng.kernel@gmail.com
> Signed-off-by: Shuangpeng Bai <shuangpeng.kernel@gmail.com>
> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> (cherry picked from commit fd73b691702170d37d66f4b0278530cea8ed419a)
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-154529
> Feature: fix ms/tracefs
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261111203529.363554-1-eva.kurchatova@virtuozzo.com?part=1


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
@ 2026-11-11 20:39   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-11 20:39 UTC (permalink / raw)
  To: khorenko, Eva Kurchatova; +Cc: devel

> From: Joseph Qi <joseph.qi@linux.alibaba.com>
> 
> Commit 1b95382da85c ("eventfs: Use children field for rcu head and add
> memory barriers") added an early bail out to the ei->children loop:
> 
> 	smp_rmb();
> 	if (ei->is_freed)
> 		return -EINVAL;
> 
> Upstream wraps eventfs_iterate() in guard(srcu)(&eventfs_srcu), so that
> return still drops the read lock. The 6.12.y backport instead brackets the
> function with srcu_read_lock() and a shared "out" label that calls
> srcu_read_unlock(), so this path returns while still holding eventfs_srcu
> for reading.
> 
> [ ... ]
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-154529
> Feature: fix ms/tracefs
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261111203529.363554-1-eva.kurchatova@virtuozzo.com?part=3


_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.1 4/4] ms/eventfs: Initialize ei->children and ei->list in init_ei()
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 4/4] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
@ 2026-11-11 20:40   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-11 20:40 UTC (permalink / raw)
  To: khorenko, Eva Kurchatova; +Cc: devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] tracefs: commit message blames eventfs_create_dir() instead of eventfs_create_events_dir()
--

commit 518d04c37ab25c6aa9068d020ccd9d857768cb9a
Author: Deepanshu Kartikey <kartikey406@gmail.com>

ms/eventfs: Initialize ei->children and ei->list in init_ei()

This patch moves the INIT_LIST_HEAD() calls for ei->children and ei->list
into init_ei(). Both eventfs_create_dir() and eventfs_create_events_dir()
then get initialized lists before any failure path can reach free_ei().

Link: https://patch.msgid.link/20260824144653.54044-1-kartikey406@gmail.com

> ms/eventfs: Initialize ei->children and ei->list in init_ei()
>
> eventfs_create_dir() allocates the eventfs_inode and initializes it with
> init_ei(). But this does not initialize the eventfs_inode list_heads. If
> the eventfs_create_dir() fails due to memory pressure, it will call
> free_ei() before it initialized the lists, and that checks to make sure
> the eventfs_inode has no children. But because the list wasn't
> initialized, it will give a false warning.

[Severity: Low]
This isn't a code bug, but is the commit message naming the right function?

Before this patch, eventfs_create_dir() already ran INIT_LIST_HEAD() on
ei->children and ei->list right after alloc_ei() and the field
assignments:

    ei = alloc_ei(name);
    if (!ei)
        return ERR_PTR(-ENOMEM);

    ei->entries = entries;
    ei->nr_entries = size;
    ei->data = data;
    INIT_LIST_HEAD(&ei->children);
    INIT_LIST_HEAD(&ei->list);

The only later cleanup_ei() call in that function comes after
list_add_tail() and list_empty(), so the lists were already initialized
there.

The path that could reach free_ei() with uninitialized (zeroed) list heads
is the failure path in eventfs_create_events_dir():

    ei = alloc_root_ei(name);
    if (!ei)
        goto fail;

    inode = tracefs_get_inode(dentry->d_sb);
    if (unlikely(!inode))
        goto fail;
    ...
 fail:
    cleanup_ei(ei);

Here the INIT_LIST_HEAD() calls ran only after those failure points.

Could the commit message be reworded to name eventfs_create_events_dir()
as the function that hit the false warning? The code change itself looks
correct, since it covers both callers.

> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> --- a/fs/tracefs/event_inode.c
> +++ b/fs/tracefs/event_inode.c
> @@ -444,6 +444,8 @@ static inline struct eventfs_inode *init_ei(struct eventfs_inode *ei, const char
>  	if (!ei->name)
>  		return NULL;
>  	kref_init(&ei->kref);
> +	INIT_LIST_HEAD(&ei->children);
> +	INIT_LIST_HEAD(&ei->list);
>  	return ei;
>  }
>  

[ ... ]

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261111203529.363554-1-eva.kurchatova@virtuozzo.com?part=4

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [Devel] [PATCH hci-8.1 2/4] ms/eventfs: Use children field for rcu head and add memory barriers
  2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 2/4] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
@ 2026-11-11 20:40   ` no-reply
  0 siblings, 0 replies; 9+ messages in thread
From: no-reply @ 2026-11-11 20:40 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko; +Cc: devel

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] tracefs: eventfs_iterate() returns with SRCU read lock held on is_freed bail-out
--

commit 2fa07daf3577d3718d95f99a986545de113bc3c8
Author: Steven Rostedt <rostedt@goodmis.org>

ms/eventfs: Use children field for rcu head and add memory barriers

This commit overlays the rcu_head with the children list head instead of
the list head in struct eventfs_inode. It adds an smp_wmb() after setting
is_freed in free_ei(). It also adds an smp_rmb() and an is_freed check at
the top of the children iteration loop in eventfs_iterate().

Link: https://patch.msgid.link/20260808094215.4252430d@robin

> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> --- a/fs/tracefs/event_inode.c
> +++ b/fs/tracefs/event_inode.c

[ ... ]

> @@ -645,6 +655,20 @@ static int eventfs_iterate(struct file *file, struct dir_context *ctx)
>  	list_for_each_entry_srcu(ei_child, &ei->children, list,
>  				 srcu_read_lock_held(&eventfs_srcu)) {
>  
> +		/*
> +		 * If the ei is being freed, then the ei->children may be
> +		 * being used as the rcu list, which means the next element
> +		 * may be garbage. The ei->is_free is set before switching
> +		 * the ei->children over to ei->rcu. The read memory barrier
> +		 * here makes sure the ei_child is read before is_free is
> +		 * updated.
> +		 *
> +		 * Matches the smp_wmb() in free_ei()
> +		 */
> +		smp_rmb();
> +		if (ei->is_freed)
> +			return -EINVAL;
> +

[Severity: Medium]
Can this early return leave eventfs_srcu read-locked?

eventfs_iterate() takes the SRCU read lock near the top:

    idx = srcu_read_lock(&eventfs_srcu);

Every other exit path in the function uses goto out or goto out_dec, which
reach srcu_read_unlock(&eventfs_srcu, idx). The bare return -EINVAL here
bypasses it.

If a readdir on an eventfs directory races with free_ei() setting
ei->is_freed, the iterator returns with the reader still registered on
eventfs_srcu. Grace periods on that domain then cannot complete.

call_srcu() callbacks such as free_ei_rcu, queued from release_ei(), would
not run. That would leak eventfs_inodes along with their names and
entry_attrs. Any synchronize_srcu() or srcu_barrier() on eventfs_srcu could
also hang.

Should this be ret = -EINVAL; goto out; instead?

The later commit in this series, "ms/eventfs: fix SRCU read lock leak in
eventfs_iterate()", changes this branch to do that, so the end state of the
series is correct. As posted, this commit is still broken and affects
bisectability.

>  		if (c > 0) {
>  			c--;
>  			continue;

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261111203529.363554-1-eva.kurchatova@virtuozzo.com?part=2

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2026-11-11 20:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 20:34 [Devel] [PATCH hci-8.1 0/4] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
2026-11-11 20:39   ` no-reply
2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 2/4] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
2026-11-11 20:40   ` no-reply
2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
2026-11-11 20:39   ` no-reply
2026-11-11 20:34 ` [Devel] [PATCH hci-8.1 4/4] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
2026-11-11 20:40   ` no-reply

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.