[PATCH v2 07/39] mount: attach mappings to mounts

Tycho Andersen tycho at tycho.pizza
Mon Nov 23 15:47:19 UTC 2020


On Sun, Nov 15, 2020 at 11:36:46AM +0100, Christian Brauner wrote:
> +static inline struct user_namespace *mnt_user_ns(const struct vfsmount *mnt)
> +{
> +	return mnt->mnt_user_ns;
> +}

I think you might want a READ_ONCE() here. Right now it seems ok, since the
mnt_user_ns can't change, but if we ever allow it to change (and I see you have
a idmapped_mounts_wip_v2_allow_to_change_idmapping branch on your public tree
:D), the pattern of,

        user_ns = mnt_user_ns(path->mnt);
        if (mnt_idmapped(path->mnt)) {
                uid = kuid_from_mnt(user_ns, uid);
                gid = kgid_from_mnt(user_ns, gid);
        }

could race.

Tycho



More information about the Linux-security-module-archive mailing list