diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2025-08-26 16:35:55 -0400 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-10-19 16:37:44 +0200 |
| commit | 7381cd12252565a83f5060ee7e9bf3aa40e9265a (patch) | |
| tree | 498a93c5a6669c1cdfa243e2efcb3ed3683b17a4 | |
| parent | b7b12f5e02e30f015888ce86cad88a8a62e61534 (diff) | |
| download | linux-7381cd12252565a83f5060ee7e9bf3aa40e9265a.tar.gz linux-7381cd12252565a83f5060ee7e9bf3aa40e9265a.tar.bz2 linux-7381cd12252565a83f5060ee7e9bf3aa40e9265a.zip | |
mnt_ns_tree_remove(): DTRT if mnt_ns had never been added to mnt_ns_list
[ Upstream commit 38f4885088fc5ad41b8b0a2a2cfc73d01e709e5c ]
Actual removal is done under the lock, but for checking if need to bother
the lockless RB_EMPTY_NODE() is safe - either that namespace had never
been added to mnt_ns_tree, in which case the the node will stay empty, or
whoever had allocated it has called mnt_ns_tree_add() and it has already
run to completion. After that point RB_EMPTY_NODE() will become false and
will remain false, no matter what we do with other nodes in the tree.
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | fs/namespace.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/namespace.c b/fs/namespace.c index 38609066cf33..fc4cbbefa70e 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -196,7 +196,7 @@ static void mnt_ns_release_rcu(struct rcu_head *rcu) static void mnt_ns_tree_remove(struct mnt_namespace *ns) { /* remove from global mount namespace list */ - if (!is_anon_ns(ns)) { + if (!RB_EMPTY_NODE(&ns->mnt_ns_tree_node)) { mnt_ns_tree_write_lock(); rb_erase(&ns->mnt_ns_tree_node, &mnt_ns_tree); list_bidir_del_rcu(&ns->mnt_ns_list); |
