]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
invent_group_ids(): zero ->mnt_group_id always implies !IS_MNT_SHARED()
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 25 Jun 2025 19:02:11 +0000 (15:02 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Sun, 29 Jun 2025 23:03:46 +0000 (19:03 -0400)
All places where we call set_mnt_shared() are guaranteed to have
non-zero ->mnt_group_id - either by explicit test, or by having
done successful invent_group_ids() covering the same mount since
we'd grabbed namespace_sem.

The opposite combination (non-zero ->mnt_group_id and !IS_MNT_SHARED())
*is* possible - it means that we have allocated group id, but didn't
get around to set_mnt_shared() yet; such state is transient -
by the time we do namespace_unlock(), we must either do set_mnt_shared()
or unroll the group id allocations by cleanup_group_ids().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
fs/namespace.c

index ca36c4a6a1439aeb6ee26c23c92b66bef271f5fe..a75438121417d0eee2b52cad80871272bca08e31 100644 (file)
@@ -2516,7 +2516,7 @@ static int invent_group_ids(struct mount *mnt, bool recurse)
        struct mount *p;
 
        for (p = mnt; p; p = recurse ? next_mnt(p, mnt) : NULL) {
-               if (!p->mnt_group_id && !IS_MNT_SHARED(p)) {
+               if (!p->mnt_group_id) {
                        int err = mnt_alloc_group_id(p);
                        if (err) {
                                cleanup_group_ids(mnt, p);