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

Tycho Andersen
2020-11-23T15:52:17Z

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