Skip to content

Commit b0d3869

Browse files
author
Al Viro
committed
propagate_one(): mnt_set_mountpoint() needs mount_lock
... to protect the modification of mp->m_count done by it. Most of the places that modify that thing also have namespace_lock held, but not all of them can do so, so we really need mount_lock here. Kudos to Piotr Krysiuk <[email protected]>, who'd spotted a related bug in pivot_root(2) (fixed unnoticed in 5.3); search for other similar turds has caught out this one. Cc: [email protected] Signed-off-by: Al Viro <[email protected]>
1 parent 3815f1b commit b0d3869

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/pnode.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,13 @@ static int propagate_one(struct mount *m)
261261
child = copy_tree(last_source, last_source->mnt.mnt_root, type);
262262
if (IS_ERR(child))
263263
return PTR_ERR(child);
264+
read_seqlock_excl(&mount_lock);
264265
mnt_set_mountpoint(m, mp, child);
266+
if (m->mnt_master != dest_master)
267+
SET_MNT_MARK(m->mnt_master);
268+
read_sequnlock_excl(&mount_lock);
265269
last_dest = m;
266270
last_source = child;
267-
if (m->mnt_master != dest_master) {
268-
read_seqlock_excl(&mount_lock);
269-
SET_MNT_MARK(m->mnt_master);
270-
read_sequnlock_excl(&mount_lock);
271-
}
272271
hlist_add_head(&child->mnt_hash, list);
273272
return count_mounts(m->mnt_ns, child);
274273
}

0 commit comments

Comments
 (0)