Skip to content

Commit 2de2a2b

Browse files
author
CKI KWF Bot
committed
Merge: CVE-2025-38498 fix permission checks for mount propagation change
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/1373 JIRA: https://issues.redhat.com/browse/RHEL-107307 CVE: CVE-2025-38498 An inconsistent application of capabilities checking was discovered in the kernel. An initial patch was proposed and merged but regressions were reported. An additional patch was posted that makes this permission checking consistent over the two areas it's used and eliminates the regression. The risk was that the reported regression would almost certainly have serious affects for our container products (at the least) so we needed to wait for this second patch. Signed-off-by: Ian Kent <ikent@redhat.com> Approved-by: Brian Foster <bfoster@redhat.com> Approved-by: Miklos Szeredi <mszeredi@redhat.com> Approved-by: Carlos Maiolino <cmaiolino@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 9fab3d9 + baa78f9 commit 2de2a2b

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

fs/namespace.c

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2673,6 +2673,19 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
26732673
return attach_recursive_mnt(mnt, p, mp, 0);
26742674
}
26752675

2676+
static int may_change_propagation(const struct mount *m)
2677+
{
2678+
struct mnt_namespace *ns = m->mnt_ns;
2679+
2680+
// it must be mounted in some namespace
2681+
if (IS_ERR_OR_NULL(ns)) // is_mounted()
2682+
return -EINVAL;
2683+
// and the caller must be admin in userns of that namespace
2684+
if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
2685+
return -EPERM;
2686+
return 0;
2687+
}
2688+
26762689
/*
26772690
* Sanity check the flags to change_mnt_propagation.
26782691
*/
@@ -2709,6 +2722,10 @@ static int do_change_type(struct path *path, int ms_flags)
27092722
return -EINVAL;
27102723

27112724
namespace_lock();
2725+
err = may_change_propagation(mnt);
2726+
if (err)
2727+
goto out_unlock;
2728+
27122729
if (type == MS_SHARED) {
27132730
err = invent_group_ids(mnt, recurse);
27142731
if (err)
@@ -3102,18 +3119,11 @@ static int do_set_group(struct path *from_path, struct path *to_path)
31023119

31033120
namespace_lock();
31043121

3105-
err = -EINVAL;
3106-
/* To and From must be mounted */
3107-
if (!is_mounted(&from->mnt))
3108-
goto out;
3109-
if (!is_mounted(&to->mnt))
3110-
goto out;
3111-
3112-
err = -EPERM;
3113-
/* We should be allowed to modify mount namespaces of both mounts */
3114-
if (!ns_capable(from->mnt_ns->user_ns, CAP_SYS_ADMIN))
3122+
err = may_change_propagation(from);
3123+
if (err)
31153124
goto out;
3116-
if (!ns_capable(to->mnt_ns->user_ns, CAP_SYS_ADMIN))
3125+
err = may_change_propagation(to);
3126+
if (err)
31173127
goto out;
31183128

31193129
err = -EINVAL;

0 commit comments

Comments
 (0)