All Virtuozzo development lists (kernel + QEMU)
 help / color / mirror / Atom feed
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
To: khorenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate()
Date: Thu, 12 Nov 2026 02:07:56 +0200	[thread overview]
Message-ID: <20261112000926.381308-6-eva.kurchatova@virtuozzo.com> (raw)
In-Reply-To: <20261112000926.381308-2-eva.kurchatova@virtuozzo.com>

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

  parent reply	other threads:[~2026-11-12  0:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Eva Kurchatova [this message]
2026-11-12  0:15   ` [Devel] [PATCH hci-8.1 v2 4/5] ms/eventfs: fix SRCU read lock leak in eventfs_iterate() 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

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=20261112000926.381308-6-eva.kurchatova@virtuozzo.com \
    --to=eva.kurchatova@virtuozzo.com \
    --cc=devel@openvz.org \
    --cc=khorenko@virtuozzo.com \
    /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 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.