Skip to content

Commit b29b29c

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-9/-/merge_requests/7292 JIRA: https://issues.redhat.com/browse/RHEL-107304 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. It's still possible this change will introduce a regression because it adds a capability check. But this check is to ensure the process making the propagation type change has the appropriate capability to do so and that should be the case. Signed-off-by: Ian Kent <ikent@redhat.com> Approved-by: Miklos Szeredi <mszeredi@redhat.com> Approved-by: Brian Foster <bfoster@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 10f3280 + 260db79 commit b29b29c

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

fs/namespace.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,6 +2311,19 @@ static int graft_tree(struct mount *mnt, struct mount *p, struct mountpoint *mp)
23112311
return attach_recursive_mnt(mnt, p, mp, false);
23122312
}
23132313

2314+
static int may_change_propagation(const struct mount *m)
2315+
{
2316+
struct mnt_namespace *ns = m->mnt_ns;
2317+
2318+
// it must be mounted in some namespace
2319+
if (IS_ERR_OR_NULL(ns)) // is_mounted()
2320+
return -EINVAL;
2321+
// and the caller must be admin in userns of that namespace
2322+
if (!ns_capable(ns->user_ns, CAP_SYS_ADMIN))
2323+
return -EPERM;
2324+
return 0;
2325+
}
2326+
23142327
/*
23152328
* Sanity check the flags to change_mnt_propagation.
23162329
*/
@@ -2347,6 +2360,10 @@ static int do_change_type(struct path *path, int ms_flags)
23472360
return -EINVAL;
23482361

23492362
namespace_lock();
2363+
err = may_change_propagation(mnt);
2364+
if (err)
2365+
goto out_unlock;
2366+
23502367
if (type == MS_SHARED) {
23512368
err = invent_group_ids(mnt, recurse);
23522369
if (err)

0 commit comments

Comments
 (0)