From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (mail.openvz.org [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id C5047803BB for ; Thu, 12 Nov 2026 00:12:43 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AC0BMuY032348; Thu, 12 Nov 2026 03:11:23 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AC0BMuY032348 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="rHrDJKBX" Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 6AC0AZLh032280 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 12 Nov 2026 03:10:36 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 6AC0AZLh032280 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4923b9fdd43so2990558f8f.3 for ; Wed, 11 Nov 2026 16:10:36 -0800 (PST) X-Gm-Message-State: APuU4Z/f0yGirXav5efs2GP/zAom9rcxFrn/dKa1KN2E8OteLXloUik0 pd9mwjO0rhc2UyC6ZhrH37Z1aVbD1P8JNLTjp1CCNY26XG5gTAVyczzmrcdDNcVbhGdOWNFQvgw DrLnyZybaqmm8B2eiihhoILKGh+KoxfnRt+NicS49KjG9+lfgVCiIug== X-Gm-Gg: AYBFou3hGCoZN31cKfTf9+kRRTR+pmzIWVPjeWmC5ImHZ/kIbTNzO2K5anasd5PZVDt tFMzEwXeMRDPZyQE3iKdT64+VxLLw2AdJry0BQb6cIHoG73p8U5/xULWeZqwQglIJUppNrj9eC/ MGWWW4z8cdj56siuUBnlt5iUZTbZ7UcF94TJOCnRu/P2PFLZanaj9tv1aj8mxFnbBfy8s6NNDgA dlR0xEF8TbMVz56dOVfd9L8DqVlWV0ivvfSI44XQ8npmjWA8Rs58aTcOdqB59R69zXdO2YEHz8o 7ZlOdkqkFg2pBSCK9wfFCVIBh3+JJAdKc8FMU2wsjsr67SmxvasCuSYPws3IKhsTlMKQBgPO8HD UO+g4VnVY1RU8XfxGperAGPeE X-Received: by 2002:a05:600c:19d0:b0:4a2:150f:1610 with SMTP id 5b1f17b1804b1-4ba09380561mr70347155e9.23.1794442230509; Wed, 11 Nov 2026 16:10:30 -0800 (PST) X-Received: by 2002:a05:600c:19d0:b0:4a2:150f:1610 with SMTP id 5b1f17b1804b1-4ba09380561mr70346775e9.23.1794442230005; Wed, 11 Nov 2026 16:10:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794442230; cv=none; d=google.com; s=arc-20260327; b=WX9syuGmXjf8qnkra/zOuyBBaTNxSTE4nzHzJLD4aanGs+bjbGI4YP0tl1601vf7PU /bw8BvweSCMlCRgV4BGR5zCyyaj+tBQOu5o6V0wUttySFUSkGdcZbdT/fDgmhPCUNDVZ g1W1MJDntVIlP+6kcz7S+L04Q99jug8r/KU62vWkAI1sBCITAgYc14JyuLRPYXDMcKAb O+0EJ/7AmVydPqbq8Nau3Oug8Wh8jU4Cv9JFOZ33AbyqHY2W0hnQ81c/qhD6pK4ZvaM4 91lcp2agPxgHzc58seSJttz/os7yoq8+yonDlBk/fdr1p+R77DXzDAEy5/JmXLgcl9V4 IEcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=4D9Eh80wQRLpQsbwYvpn7+V9tu9ZJNOVDWwwlrIvpng=; fh=WpT6aB7RBAGHZeWZzqAr71yzRFbPTYkPWKsRagLn48Q=; b=nf+I+AuyJwZN4Lre300lzeNhNKgsgJP7uHX2bEUAC6xx+ZtT2jHMoNqZbyK87mkehK XfhvZQtlHdCuqPMb6BU+xnmkmwbOppZfjBxNwWze3DP+jMvmsKt6q/BYaPMFJc3F54EX BWgHiNzS6xjiflIvGnX9XrPBS4qOe7gNnEk0PCizNScaDY4zVqb4pEO6BnD+BG4cvgBE FO48wpOUNHT+1ziTunQFy107DYaNJv+1Q3qxXvT1xEJPRRZliWLNcv+QzZPYJHRj3jZz K1ir6glVftxa9l4mYKIqNJsLfuN1xwcokRtHQZPPHEiIZKw7w5FpDInNWtsYccWjKSHq toxQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=rHrDJKBX; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-498364d6c17si12700913f8f.252.2026.11.11.16.10.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Nov 2026 16:10:29 -0800 (PST) Received-SPF: pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=rHrDJKBX; spf=pass (google.com: domain of eva.kurchatova@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=eva.kurchatova@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=4D9Eh80wQRLpQsbwYvpn7+V9tu9ZJNOVDWwwlrIvpng=; b=rHrDJKBXoz/I G5L47OPZMLQFMKkuhrqqMlfLXuP+Y5Hb+wGeuwR74YE/DBqOa/YmzevvCAQ4p/CxpDbcI6aROOH5J gIoNMATDMiYWU90piI6W8SgEMogCy0DfspZtsKkLLoFyXnKUKPmtFwS53rKy6acioN+sbLxZ5LjoA ZyLL7DZTtOrhxcswplXsonfDUXeRl4UnsueBPzlxM48P2C3NtvEMx/TB7T1qtETBFDW1d2Fd0B3KI nCBG4gwM+s0sP1g9QIqgSeVGKR26BwE821+t0M+3R3FD0j1R8PsMqT7bAOM1QWktgFoZJIADHLdQz +0OJCldakDJBT7HOtqtUJQ==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1xRIKQ-002DgU-3B; Thu, 12 Nov 2026 01:10:26 +0100 From: Eva Kurchatova To: khorenko@virtuozzo.com Date: Thu, 12 Nov 2026 02:07:53 +0200 Message-ID: <20261112000926.381308-3-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261112000926.381308-2-eva.kurchatova@virtuozzo.com> References: <20261112000926.381308-2-eva.kurchatova@virtuozzo.com> MIME-Version: 1.0 X-OZ-Fwd: true Cc: devel@openvz.org Subject: [Devel] [PATCH hci-8.1 v2 1/5] ms/eventfs: Hold eventfs_mutex and SRCU when remount walks events X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org From: David Carlier 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 Signed-off-by: Steven Rostedt (cherry picked from commit 07004a8c4b572171934390148ee48c4175c77eed) https://virtuozzo.atlassian.net/browse/VSTOR-154529 Feature: fix ms/tracefs Signed-off-by: Eva Kurchatova --- 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// */ 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