mirror of
https://gitee.com/bianbu-linux/linux-6.6
synced 2025-04-24 14:07:52 -04:00
fs: use type safe idmapping helpers
We already ported most parts and filesystems over for v6.0 to the new vfs{g,u}id_t type and associated helpers for v6.0. Convert the remaining places so we can remove all the old helpers. This is a non-functional change. Reviewed-by: Seth Forshee (DigitalOcean) <sforshee@kernel.org> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
This commit is contained in:
parent
9c4f28ddfb
commit
a2bd096fb2
6 changed files with 40 additions and 37 deletions
16
fs/exec.c
16
fs/exec.c
|
@ -1591,8 +1591,8 @@ static void bprm_fill_uid(struct linux_binprm *bprm, struct file *file)
|
|||
struct user_namespace *mnt_userns;
|
||||
struct inode *inode = file_inode(file);
|
||||
unsigned int mode;
|
||||
kuid_t uid;
|
||||
kgid_t gid;
|
||||
vfsuid_t vfsuid;
|
||||
vfsgid_t vfsgid;
|
||||
|
||||
if (!mnt_may_suid(file->f_path.mnt))
|
||||
return;
|
||||
|
@ -1611,23 +1611,23 @@ static void bprm_fill_uid(struct linux_binprm *bprm, struct file *file)
|
|||
|
||||
/* reload atomically mode/uid/gid now that lock held */
|
||||
mode = inode->i_mode;
|
||||
uid = i_uid_into_mnt(mnt_userns, inode);
|
||||
gid = i_gid_into_mnt(mnt_userns, inode);
|
||||
vfsuid = i_uid_into_vfsuid(mnt_userns, inode);
|
||||
vfsgid = i_gid_into_vfsgid(mnt_userns, inode);
|
||||
inode_unlock(inode);
|
||||
|
||||
/* We ignore suid/sgid if there are no mappings for them in the ns */
|
||||
if (!kuid_has_mapping(bprm->cred->user_ns, uid) ||
|
||||
!kgid_has_mapping(bprm->cred->user_ns, gid))
|
||||
if (!vfsuid_has_mapping(bprm->cred->user_ns, vfsuid) ||
|
||||
!vfsgid_has_mapping(bprm->cred->user_ns, vfsgid))
|
||||
return;
|
||||
|
||||
if (mode & S_ISUID) {
|
||||
bprm->per_clear |= PER_CLEAR_ON_SETID;
|
||||
bprm->cred->euid = uid;
|
||||
bprm->cred->euid = vfsuid_into_kuid(vfsuid);
|
||||
}
|
||||
|
||||
if ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP)) {
|
||||
bprm->per_clear |= PER_CLEAR_ON_SETID;
|
||||
bprm->cred->egid = gid;
|
||||
bprm->cred->egid = vfsgid_into_kgid(vfsgid);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue