Skip to content

Commit 7381cd1

Browse files
Al Virogregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Al Viro <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent b7b12f5 commit 7381cd1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/namespace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void mnt_ns_release_rcu(struct rcu_head *rcu)
196196
static void mnt_ns_tree_remove(struct mnt_namespace *ns)
197197
{
198198
/* remove from global mount namespace list */
199-
if (!is_anon_ns(ns)) {
199+
if (!RB_EMPTY_NODE(&ns->mnt_ns_tree_node)) {
200200
mnt_ns_tree_write_lock();
201201
rb_erase(&ns->mnt_ns_tree_node, &mnt_ns_tree);
202202
list_bidir_del_rcu(&ns->mnt_ns_list);

0 commit comments

Comments
 (0)