From: David Carlier <[email protected]>

[ 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: [email protected]
Link: https://patch.msgid.link/[email protected]
Signed-off-by: David Carlier <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
[ adapted scoped_guard(mutex, &eventfs_mutex) block to explicit 
mutex_lock()/mutex_unlock() pair ]
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
(cherry picked from commit 1801ce6ce6f9f1df134987e6bc47d28c1ebe9a51)

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

Signed-off-by: Eva Kurchatova <[email protected]>
---
 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
[email protected]
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to