Skip to content

Commit c9fa2b0

Browse files
committed
mnt_idmapping: add vfs[g,u]id_into_k[g,u]id()
Add two tiny helpers to conver a vfsuid into a kuid. Signed-off-by: Christian Brauner (Microsoft) <[email protected]>
1 parent 45598fd commit c9fa2b0

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

include/linux/mnt_idmapping.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,19 @@ static inline bool vfsuid_has_fsmapping(struct user_namespace *mnt_userns,
333333
return uid_valid(from_vfsuid(mnt_userns, fs_userns, vfsuid));
334334
}
335335

336+
/**
337+
* vfsuid_into_kuid - convert vfsuid into kuid
338+
* @vfsuid: the vfsuid to convert
339+
*
340+
* This can be used when a vfsuid is committed as a kuid.
341+
*
342+
* Return: a kuid with the value of @vfsuid
343+
*/
344+
static inline kuid_t vfsuid_into_kuid(vfsuid_t vfsuid)
345+
{
346+
return AS_KUIDT(vfsuid);
347+
}
348+
336349
/**
337350
* from_vfsgid - map a vfsgid into the filesystem idmapping
338351
* @mnt_userns: the mount's idmapping
@@ -406,6 +419,19 @@ static inline bool vfsgid_has_fsmapping(struct user_namespace *mnt_userns,
406419
return gid_valid(from_vfsgid(mnt_userns, fs_userns, vfsgid));
407420
}
408421

422+
/**
423+
* vfsgid_into_kgid - convert vfsgid into kgid
424+
* @vfsgid: the vfsgid to convert
425+
*
426+
* This can be used when a vfsgid is committed as a kgid.
427+
*
428+
* Return: a kgid with the value of @vfsgid
429+
*/
430+
static inline kgid_t vfsgid_into_kgid(vfsgid_t vfsgid)
431+
{
432+
return AS_KGIDT(vfsgid);
433+
}
434+
409435
/**
410436
* mapped_fsuid - return caller's fsuid mapped up into a mnt_userns
411437
* @mnt_userns: the mount's idmapping

0 commit comments

Comments
 (0)