All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
* [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference
@ 2026-11-12  0:07 Eva Kurchatova
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events Eva Kurchatova
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Eva Kurchatova @ 2026-11-12  0:07 UTC (permalink / raw)
  To: khorenko; +Cc: devel

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

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

Changes in v2:
- Add "ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events",
  which 6.12.y also takes.

Link to v1: http://lore.virtuozzo.com/kernel/20261111203529.363554-1-eva.kurchatova@virtuozzo.com/T/#t

David Carlier (1):
  ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events

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 | 51 ++++++++++++++++++++++++++++++++++------
 fs/tracefs/inode.c       |  5 +++-
 fs/tracefs/internal.h    |  7 ++++--
 3 files changed, 53 insertions(+), 10 deletions(-)

-- 
2.56.0

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

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

* [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
@ 2026-11-12  0:07 ` Eva Kurchatova
  2026-11-12  0:15   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
                   ` (5 subsequent siblings)
  6 siblings, 2 replies; 19+ messages in thread
From: Eva Kurchatova @ 2026-11-12  0:07 UTC (permalink / raw)
  To: khorenko; +Cc: devel

From: David Carlier <devnexen@gmail.com>

Commit 340f0c7067a9 ("eventfs: Update all the eventfs_inodes from the
events descriptor") had eventfs_set_attrs() recurse through ei->children
on remount.  The walk only holds the rcu_read_lock() taken by
tracefs_apply_options() over tracefs_inodes, which is wrong:

  - list_for_each_entry over ei->children races with the list_del_rcu()
    in eventfs_remove_rec() -- LIST_POISON1 deref, same shape as
    d2603279c7d6.
  - eventfs_inodes are freed via call_srcu(&eventfs_srcu, ...).
    rcu_read_lock() does not extend an SRCU grace period, so ti->private
    can be reclaimed under the walk.
  - The writes to ei->attr race with eventfs_set_attr(), which holds
    eventfs_mutex.

Reproducer:

  while :; do mount -o remount,uid=$((RANDOM%1000)) /sys/kernel/tracing; done &
  while :; do
      echo "p:kp submit_bio" > /sys/kernel/tracing/kprobe_events
      echo > /sys/kernel/tracing/kprobe_events
  done

Wrap the events portion of tracefs_apply_options() in
eventfs_remount_lock()/_unlock() that take eventfs_mutex and
srcu_read_lock(&eventfs_srcu).  eventfs_set_attrs() doesn't sleep so the
nested rcu_read_lock() is fine; lockdep_assert_held() pins the contract.

Comment in tracefs_drop_inode() said "RCU cycle" -- it is SRCU.

Fixes: 340f0c7067a9 ("eventfs: Update all the eventfs_inodes from the events descriptor")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260418191737.10289-1-devnexen@gmail.com
Signed-off-by: David Carlier <devnexen@gmail.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
(cherry picked from commit 07004a8c4b572171934390148ee48c4175c77eed)

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 | 14 ++++++++++++++
 fs/tracefs/inode.c       |  5 ++++-
 fs/tracefs/internal.h    |  3 +++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 8705c77a9e75..ce61795a7ed5 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -250,6 +250,8 @@ static void eventfs_set_attrs(struct eventfs_inode *ei, bool update_uid, kuid_t
 {
 	struct eventfs_inode *ei_child;
 
+	lockdep_assert_held(&eventfs_mutex);
+
 	/* Update events/<system>/<event> */
 	if (WARN_ON_ONCE(level > 3))
 		return;
@@ -911,3 +913,15 @@ void eventfs_remove_events_dir(struct eventfs_inode *ei)
 	d_invalidate(dentry);
 	dput(dentry);
 }
+
+int eventfs_remount_lock(void)
+{
+	mutex_lock(&eventfs_mutex);
+	return srcu_read_lock(&eventfs_srcu);
+}
+
+void eventfs_remount_unlock(int srcu_idx)
+{
+	srcu_read_unlock(&eventfs_srcu, srcu_idx);
+	mutex_unlock(&eventfs_mutex);
+}
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 9f15d606dfde..8e5db8cc4218 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -336,6 +336,7 @@ static int tracefs_apply_options(struct super_block *sb, bool remount)
 	struct inode *inode = d_inode(sb->s_root);
 	struct tracefs_inode *ti;
 	bool update_uid, update_gid;
+	int srcu_idx;
 	umode_t tmp_mode;
 
 	/*
@@ -360,6 +361,7 @@ static int tracefs_apply_options(struct super_block *sb, bool remount)
 		update_uid = fsi->opts & BIT(Opt_uid);
 		update_gid = fsi->opts & BIT(Opt_gid);
 
+		srcu_idx = eventfs_remount_lock();
 		rcu_read_lock();
 		list_for_each_entry_rcu(ti, &tracefs_inodes, list) {
 			if (update_uid) {
@@ -381,6 +383,7 @@ static int tracefs_apply_options(struct super_block *sb, bool remount)
 				eventfs_remount(ti, update_uid, update_gid);
 		}
 		rcu_read_unlock();
+		eventfs_remount_unlock(srcu_idx);
 	}
 
 	return 0;
@@ -426,7 +429,7 @@ static int tracefs_drop_inode(struct inode *inode)
 	 * This inode is being freed and cannot be used for
 	 * eventfs. Clear the flag so that it doesn't call into
 	 * eventfs during the remount flag updates. The eventfs_inode
-	 * gets freed after an RCU cycle, so the content will still
+	 * gets freed after an SRCU cycle, so the content will still
 	 * be safe if the iteration is going on now.
 	 */
 	ti->flags &= ~TRACEFS_EVENT_INODE;
diff --git a/fs/tracefs/internal.h b/fs/tracefs/internal.h
index d83c2a25f288..a4a7f8431aff 100644
--- a/fs/tracefs/internal.h
+++ b/fs/tracefs/internal.h
@@ -76,4 +76,7 @@ struct inode *tracefs_get_inode(struct super_block *sb);
 void eventfs_remount(struct tracefs_inode *ti, bool update_uid, bool update_gid);
 void eventfs_d_release(struct dentry *dentry);
 
+int eventfs_remount_lock(void);
+void eventfs_remount_unlock(int srcu_idx);
+
 #endif /* _TRACEFS_INTERNAL_H */
-- 
2.56.0

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

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

* [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec()
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events Eva Kurchatova
@ 2026-11-12  0:07 ` Eva Kurchatova
  2026-11-12  0:13   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 19+ messages in thread
From: Eva Kurchatova @ 2026-11-12  0:07 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] 19+ messages in thread

* [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events Eva Kurchatova
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
@ 2026-11-12  0:07 ` Eva Kurchatova
  2026-11-12  0:16   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
                   ` (3 subsequent siblings)
  6 siblings, 2 replies; 19+ messages in thread
From: Eva Kurchatova @ 2026-11-12  0:07 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] 19+ messages in thread

* [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
                   ` (2 preceding siblings ...)
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
@ 2026-11-12  0:07 ` Eva Kurchatova
  2026-11-12  0:15   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
                   ` (2 subsequent siblings)
  6 siblings, 2 replies; 19+ messages in thread
From: Eva Kurchatova @ 2026-11-12  0:07 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] 19+ messages in thread

* [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei()
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
                   ` (3 preceding siblings ...)
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
@ 2026-11-12  0:07 ` Eva Kurchatova
  2026-11-12  0:16   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  2026-11-12 16:43 ` [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Konstantin Khorenko
  2026-11-12 16:50 ` Konstantin Khorenko
  6 siblings, 2 replies; 19+ messages in thread
From: Eva Kurchatova @ 2026-11-12  0:07 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] 19+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec()
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
@ 2026-11-12  0:13   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-12  0:13 UTC (permalink / raw)
  To: khorenko, Eva Kurchatova; +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>

This patch is unchanged since "[Devel] [PATCH hci-8.1 1/4] ms/eventfs: Fix use-after-free in eventfs_remove_rec()", which Sashiko reviewed and found no issues in. That review applies to this posting unaltered, so the patch has not been reviewed again.

-- 
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] 19+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
@ 2026-11-12  0:15   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-12  0:15 UTC (permalink / raw)
  To: Eva Kurchatova, 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.
> 
> [ ... ]
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-154529
> Feature: fix ms/tracefs
> 
> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>

This patch is unchanged since "[Devel] [PATCH hci-8.1 3/4] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()", which Sashiko reviewed and found no issues in. That review applies to this posting unaltered, so the patch has not been reviewed again.

-- 
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] 19+ messages in thread

* Re: [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events Eva Kurchatova
@ 2026-11-12  0:15   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-12  0:15 UTC (permalink / raw)
  To: khorenko, Eva Kurchatova; +Cc: devel

> From: David Carlier <devnexen@gmail.com>
> 
> Commit 340f0c7067a9 ("eventfs: Update all the eventfs_inodes from the
> events descriptor") had eventfs_set_attrs() recurse through ei->children
> on remount.  The walk only holds the rcu_read_lock() taken by
> tracefs_apply_options() over tracefs_inodes, which is wrong:
> 
>   - list_for_each_entry over ei->children races with the list_del_rcu()
>     in eventfs_remove_rec() -- LIST_POISON1 deref, same shape as
>     d2603279c7d6.
>   - eventfs_inodes are freed via call_srcu(&eventfs_srcu, ...).
>     rcu_read_lock() does not extend an SRCU grace period, so ti->private
>     can be reclaimed under the walk.
>   - The writes to ei->attr race with eventfs_set_attr(), which holds
>     eventfs_mutex.
> [ ... ]
> 
> 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/20261112000926.381308-2-eva.kurchatova@virtuozzo.com?part=1


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

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

* Re: [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei()
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
@ 2026-11-12  0:16   ` no-reply
  2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: no-reply @ 2026-11-12  0:16 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 names eventfs_create_dir() but the fix targets eventfs_create_events_dir()
--

commit 9d0d1df3c54a5c4e101ce47e1ff3727b67a3af30
Author: Deepanshu Kartikey <kartikey406@gmail.com>

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

This commit moves the INIT_LIST_HEAD() calls for ei->children and ei->list
into init_ei(), so every eventfs_inode gets initialized lists at allocation
time. The calls are removed from eventfs_create_dir() and
eventfs_create_events_dir().

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

The commit message has an inaccuracy about which function is affected.

> 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]
Is this description accurate for eventfs_create_dir()?

In eventfs_create_dir(), alloc_ei() is followed directly by plain field
assignments, and the list initialization came right after those:

fs/tracefs/event_inode.c:eventfs_create_dir() {
    ...
	ei = alloc_ei(name);
	if (!ei)
		return ERR_PTR(-ENOMEM);

	ei->entries = entries;
	ei->nr_entries = size;
	ei->data = data;
    ...
}

There is no failure window between init_ei() and the old INIT_LIST_HEAD()
calls. If alloc_ei() fails, free_ei() is not reached. The only
cleanup_ei() call runs after the lists were already initialized, so the
WARN_ON_ONCE(!list_empty(&ei->children)) in free_ei() cannot fire falsely
there.

The false warning looks reachable in eventfs_create_events_dir(), where
alloc_root_ei() succeeds and tracefs_get_inode() then fails:

fs/tracefs/event_inode.c: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);
	tracefs_failed_creating(dentry);
    ...
}

On that path the lists were still zeroed from kzalloc, so list_empty() on
ei->children returns false and the warning fires. The code change covers
this path too, since init_ei() is shared by alloc_ei() and alloc_root_ei().

Could the commit message name eventfs_create_events_dir() as the function
whose failure path triggered the warning? The text is the same as in the
upstream commit, so this does not affect the code change itself.

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

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

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

* Re: [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
@ 2026-11-12  0:16   ` no-reply
  2026-11-12  4:18     ` Eva Kurchatova (Virtuozzo)
  2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 1 reply; 19+ messages in thread
From: no-reply @ 2026-11-12  0:16 UTC (permalink / raw)
  To: Eva Kurchatova, khorenko; +Cc: devel

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] tracefs: eventfs_iterate() returns -EINVAL without srcu_read_unlock()
- [Medium] tracefs: free_ei() WARN_ON_ONCE fires on uninitialised children list
--

Commit 02dabdf68279c061e3542bcb12e5c799c6b10fbf
Author: Steven Rostedt <rostedt@goodmis.org>

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

This commit moves the rcu_head into a union with the children list instead
of the list field. It adds a smp_wmb() in free_ei() after setting is_freed.
It also adds a smp_rmb() and an is_freed check at the top of the SRCU
children 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

[ ... ]

> @@ -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));

[Severity: Medium]
Can this WARN_ON_ONCE() fire spuriously on an eventfs_inode whose children
list was never initialized?

In eventfs_create_events_dir(), ei comes from kzalloc(), so
ei->children.next is NULL. If tracefs_get_inode() fails:

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

this happens before INIT_LIST_HEAD(&ei->children) runs. list_empty() tests
head->next == head, which is false for NULL, so
WARN_ON_ONCE(!list_empty(&ei->children)) triggers although there are no
children. On systems with panic_on_warn this would be a panic.

This is fixed later in the series by 9d0d1df3c54a ("Initialize ei->children
and ei->list in init_ei()"), which moves the INIT_LIST_HEAD calls into
init_ei(). The warning is incorrect in this commit alone.

>  		ei->is_freed = 1;

[ ... ]

> @@ -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)) {
>  
> +		/*

[ ... ]

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

[Severity: High]
Does this early return leak the SRCU read lock?

eventfs_iterate() takes idx = srcu_read_lock(&eventfs_srcu) at the top, and
the only srcu_read_unlock() is at the out: label:

eventfs_iterate()
    idx = srcu_read_lock(&eventfs_srcu);
    ...
    list_for_each_entry_srcu(...) {
        smp_rmb();
        if (ei->is_freed)
            return -EINVAL;    <- bypasses out:
    ...
 out:
    srcu_read_unlock(&eventfs_srcu, idx);

When a concurrent eventfs_remove_rec()/free_ei() sets is_freed during a
getdents(), this path is reachable. The eventfs_srcu grace period then
cannot complete, so the call_srcu() callbacks queued by release_ei() never
run. That would leak the eventfs inodes, names and entry_attrs, and could
hang any synchronize_srcu() or srcu_barrier() on that domain.

Would "ret = -EINVAL; goto out;" be the right form here?

This is fixed later in the series by 64fdb88769c6 ("ms/eventfs: fix SRCU
read lock leak in eventfs_iterate()"), which replaces the bare return with
that form. The regression is present in this commit, which affects
bisectability.

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

[ ... ]

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

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

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

* Re: [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers
  2026-11-12  0:16   ` no-reply
@ 2026-11-12  4:18     ` Eva Kurchatova (Virtuozzo)
  0 siblings, 0 replies; 19+ messages in thread
From: Eva Kurchatova (Virtuozzo) @ 2026-11-12  4:18 UTC (permalink / raw)
  To: no-reply, khorenko; +Cc: devel


On 11/12/26 02:16, no-reply@sashiko.virtuozzo.com wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] tracefs: eventfs_iterate() returns -EINVAL without srcu_read_unlock()
> - [Medium] tracefs: free_ei() WARN_ON_ONCE fires on uninitialised children list
> --
>
> Commit 02dabdf68279c061e3542bcb12e5c799c6b10fbf
> Author: Steven Rostedt <rostedt@goodmis.org>
>
> ms/eventfs: Use children field for rcu head and add memory barriers
>
> This commit moves the rcu_head into a union with the children list instead
> of the list field. It adds a smp_wmb() in free_ei() after setting is_freed.
> It also adds a smp_rmb() and an is_freed check at the top of the SRCU
> children 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
> [ ... ]
>
>> @@ -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));
> [Severity: Medium]
> Can this WARN_ON_ONCE() fire spuriously on an eventfs_inode whose children
> list was never initialized?
>
> In eventfs_create_events_dir(), ei comes from kzalloc(), so
> ei->children.next is NULL. If tracefs_get_inode() fails:
>
> eventfs_create_events_dir()
>      inode = tracefs_get_inode(dentry->d_sb);
>      if (unlikely(!inode))
>          goto fail;
>      ...
> fail:
>      cleanup_ei() / free_ei()
>
> this happens before INIT_LIST_HEAD(&ei->children) runs. list_empty() tests
> head->next == head, which is false for NULL, so
> WARN_ON_ONCE(!list_empty(&ei->children)) triggers although there are no
> children. On systems with panic_on_warn this would be a panic.
>
> This is fixed later in the series by 9d0d1df3c54a ("Initialize ei->children
> and ei->list in init_ei()"), which moves the INIT_LIST_HEAD calls into
> init_ei(). The warning is incorrect in this commit alone.
>
>>   		ei->is_freed = 1;
> [ ... ]
>
>> @@ -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)) {
>>   
>> +		/*
> [ ... ]
>
>> +		smp_rmb();
>> +		if (ei->is_freed)
>> +			return -EINVAL;
> [Severity: High]
> Does this early return leak the SRCU read lock?
>
> eventfs_iterate() takes idx = srcu_read_lock(&eventfs_srcu) at the top, and
> the only srcu_read_unlock() is at the out: label:
>
> eventfs_iterate()
>      idx = srcu_read_lock(&eventfs_srcu);
>      ...
>      list_for_each_entry_srcu(...) {
>          smp_rmb();
>          if (ei->is_freed)
>              return -EINVAL;    <- bypasses out:
>      ...
>   out:
>      srcu_read_unlock(&eventfs_srcu, idx);
>
> When a concurrent eventfs_remove_rec()/free_ei() sets is_freed during a
> getdents(), this path is reachable. The eventfs_srcu grace period then
> cannot complete, so the call_srcu() callbacks queued by release_ei() never
> run. That would leak the eventfs inodes, names and entry_attrs, and could
> hang any synchronize_srcu() or srcu_barrier() on that domain.
>
> Would "ret = -EINVAL; goto out;" be the right form here?
>
> This is fixed later in the series by 64fdb88769c6 ("ms/eventfs: fix SRCU
> read lock leak in eventfs_iterate()"), which replaces the bare return with
> that form. The regression is present in this commit, which affects
> bisectability.
>
>>   		if (c > 0) {
>>   			c--;
>>   			continue;
> [ ... ]


Both issues are present only at this step (3/5), and are fixed later in 
the series: the SRCU leak by 4/5 and the WARN by 5/5. Tree 6.12.y has 
the same split (1b95382da85c, then 9e8999106959). The patches are kept 
verbatim so they match 6.12.y exactly.

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

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

* Re: [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
                   ` (4 preceding siblings ...)
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
@ 2026-11-12 16:43 ` Konstantin Khorenko
  2026-11-12 16:50 ` Konstantin Khorenko
  6 siblings, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:43 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying with these fixes on my side:
- moved 5/5 "ms/eventfs: Initialize ei->children and ei->list in
  init_ei()" in front of 3/5, no other change.

On Thu, 12 Nov 2026 02:07:52 +0200, Eva Kurchatova <eva.kurchatova@virtuozzo.com> wrote:
> David Carlier (1):
>   ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events
>
> 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

The backports match their mainline and 6.12.y originals, and the end
state fixes the eventfs_iterate() oops. 6.12.y applies the init_ei()
fix before 1b95382da85c, so with the reorder the order is the same as
there and 3/5 no longer warns on the events dir failure path.

Separate patches, not needed for this series; I created a task for
each:

1. 6.12.y 1801ce6ce6f9 (mainline f67950b2887f, "eventfs: Use
   list_add_tail_rcu() for SRCU-protected children list").
   eventfs_create_dir() still publishes the child with a plain
   list_add_tail() on the list that eventfs_iterate() walks under
   SRCU. It is Cc stable and from the same family as 1/5.
   https://virtuozzo.atlassian.net/browse/VSTOR-154848

2. Mainline 2cd88c498ecf ("eventfs: Free the eventfs_inode after an
   rcu grace period too"), Cc stable. tracefs_d_revalidate() reads
   ei->is_freed in RCU path walk, but the ei is freed after an SRCU
   grace period only, which does not wait for rcu_read_lock()
   sections.
   https://virtuozzo.atlassian.net/browse/VSTOR-154849

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

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

* Re: [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec()
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
  2026-11-12  0:13   ` no-reply
@ 2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:43 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying as is.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

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

* Re: [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events Eva Kurchatova
  2026-11-12  0:15   ` no-reply
@ 2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:43 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying as is.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

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

* Re: [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
  2026-11-12  0:16   ` no-reply
@ 2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:43 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying with these fixes on my side:
- put 5/5 "ms/eventfs: Initialize ei->children and ei->list in
  init_ei()" in front of this patch.

On Thu, 12 Nov 2026 02:07:55 +0200, Eva Kurchatova <eva.kurchatova@virtuozzo.com> wrote:
>  	if (ei) {
> +		/* The ei should have no children if it is being freed. */
> +		WARN_ON_ONCE(!list_empty(&ei->children));
>  		ei->is_freed = 1;

Why: at this patch eventfs_create_events_dir() can still reach
cleanup_ei() with the list heads zeroed by kzalloc(), when
tracefs_get_inode() fails, and this WARN fires there.

Your answer to Sashiko holds for the SRCU leak, but not for the WARN:
6.12.y took the init_ei() fix (c480f8af173d, v6.12.109) before
1b95382da85c, so it never had that window. 5/5 moves in front of this
patch without any change, the final tree stays the same.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

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

* Re: [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
  2026-11-12  0:15   ` no-reply
@ 2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:43 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying as is.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

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

* Re: [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei()
  2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
  2026-11-12  0:16   ` no-reply
@ 2026-11-12 16:43   ` Konstantin Khorenko
  1 sibling, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:43 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

Applying with these fixes on my side:
- put this patch in front of 3/5 "ms/eventfs: Use children field for
  rcu head and add memory barriers", the order 6.12.y uses.

On Thu, 12 Nov 2026 02:07:57 +0200, Eva Kurchatova <eva.kurchatova@virtuozzo.com> wrote:
> 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.

Sashiko is right that the warning comes from
eventfs_create_events_dir(), not eventfs_create_dir(). The text is the
mainline one, so I keep it as is.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

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

* Re: [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference
  2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
                   ` (5 preceding siblings ...)
  2026-11-12 16:43 ` [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Konstantin Khorenko
@ 2026-11-12 16:50 ` Konstantin Khorenko
  6 siblings, 0 replies; 19+ messages in thread
From: Konstantin Khorenko @ 2026-11-12 16:50 UTC (permalink / raw)
  To: Eva Kurchatova; +Cc: devel

On Thu, 12 Nov 2026 02:07:52 +0200, Eva Kurchatova wrote:
> ms/eventfs: fix kernel panic on NULL dereference
> 
> Patchset for task https://virtuozzo.atlassian.net/browse/VSTOR-154529
> 
> Note: Two of the patches are cherry-picks from 6.12.y stable tree
> backport, as the code differs in the mainline.
> 
> [...]

Applied to branch-rh10-6.12.0-211.52.1.22.x.vz10-ovz, will be released in rh10-6.12.0-211.52.1.22.21.vz10, thanks!

[1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/5c4a6a9742ee
[2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec()
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/f964cc4ac71a
[3/5] ms/eventfs: Initialize ei->children and ei->list in init_ei()
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/d5a703a52eb1
[4/5] ms/eventfs: Use children field for rcu head and add memory barriers
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/f7e44a71e469
[5/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
      https://bitbucket.org/virtuozzocore/vzkernel.vzs/commits/3751e32064ff

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team


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

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

end of thread, other threads:[~2026-11-12 16:52 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12  0:07 [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Eva Kurchatova
2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events Eva Kurchatova
2026-11-12  0:15   ` no-reply
2026-11-12 16:43   ` Konstantin Khorenko
2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 2/5] ms/eventfs: Fix use-after-free in eventfs_remove_rec() Eva Kurchatova
2026-11-12  0:13   ` no-reply
2026-11-12 16:43   ` Konstantin Khorenko
2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 3/5] ms/eventfs: Use children field for rcu head and add memory barriers Eva Kurchatova
2026-11-12  0:16   ` no-reply
2026-11-12  4:18     ` Eva Kurchatova (Virtuozzo)
2026-11-12 16:43   ` Konstantin Khorenko
2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() Eva Kurchatova
2026-11-12  0:15   ` no-reply
2026-11-12 16:43   ` Konstantin Khorenko
2026-11-12  0:07 ` [Devel] [PATCH hci-8.1 v2 5/5] ms/eventfs: Initialize ei->children and ei->list in init_ei() Eva Kurchatova
2026-11-12  0:16   ` no-reply
2026-11-12 16:43   ` Konstantin Khorenko
2026-11-12 16:43 ` [Devel] [PATCH hci-8.1 v2 0/5] ms/eventfs: fix kernel panic on NULL dereference Konstantin Khorenko
2026-11-12 16:50 ` Konstantin Khorenko

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.