From: Al Viro Date: Wed, 4 Jun 2025 16:27:08 +0000 (-0400) Subject: do_change_type(): refuse to operate on unmounted/not ours mounts X-Git-Tag: v5.10.239~248 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c7d11fdf8e5db5f34a6c062c7e6ba3a0971879d2;p=thirdparty%2Fkernel%2Fstable.git do_change_type(): refuse to operate on unmounted/not ours mounts [ Upstream commit 12f147ddd6de7382dad54812e65f3f08d05809fc ] Ensure that propagation settings can only be changed for mounts located in the caller's mount namespace. This change aligns permission checking with the rest of mount(2). Reviewed-by: Christian Brauner Fixes: 07b20889e305 ("beginning of the shared-subtree proper") Reported-by: "Orlando, Noah" Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- diff --git a/fs/namespace.c b/fs/namespace.c index 869cc6e06d889..2d5af6653cd11 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -2308,6 +2308,10 @@ static int do_change_type(struct path *path, int ms_flags) return -EINVAL; namespace_lock(); + if (!check_mnt(mnt)) { + err = -EINVAL; + goto out_unlock; + } if (type == MS_SHARED) { err = invent_group_ids(mnt, recurse); if (err)