aboutsummaryrefslogtreecommitdiffstats
path: root/include/os/linux/spl/sys/cred.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/os/linux/spl/sys/cred.h')
-rw-r--r--include/os/linux/spl/sys/cred.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/include/os/linux/spl/sys/cred.h b/include/os/linux/spl/sys/cred.h
index 75ad400d3..7fd5f6448 100644
--- a/include/os/linux/spl/sys/cred.h
+++ b/include/os/linux/spl/sys/cred.h
@@ -48,6 +48,8 @@ extern struct task_struct init_task;
#define SGID_TO_KGID(x) (KGIDT_INIT(x))
#define KGIDP_TO_SGIDP(x) (&(x)->val)
+extern zidmap_t *zfs_get_init_idmap(void);
+
/* Check if the user ns is the initial one */
static inline boolean_t
zfs_is_init_userns(struct user_namespace *user_ns)
@@ -74,36 +76,39 @@ static inline boolean_t zfs_no_idmapping(struct user_namespace *mnt_userns,
return (zfs_is_init_userns(mnt_userns) || mnt_userns == fs_userns);
}
-static inline uid_t zfs_uid_to_vfsuid(struct user_namespace *mnt_userns,
+static inline uid_t zfs_uid_to_vfsuid(zidmap_t *mnt_userns,
struct user_namespace *fs_userns, uid_t uid)
{
- if (zfs_no_idmapping(mnt_userns, fs_userns))
+ struct user_namespace *owner = idmap_owner(mnt_userns);
+ if (zfs_no_idmapping(owner, fs_userns))
return (uid);
if (!zfs_is_init_userns(fs_userns))
uid = from_kuid(fs_userns, KUIDT_INIT(uid));
if (uid == (uid_t)-1)
return (uid);
- return (__kuid_val(make_kuid(mnt_userns, uid)));
+ return (__kuid_val(make_kuid(owner, uid)));
}
-static inline gid_t zfs_gid_to_vfsgid(struct user_namespace *mnt_userns,
+static inline gid_t zfs_gid_to_vfsgid(zidmap_t *mnt_userns,
struct user_namespace *fs_userns, gid_t gid)
{
- if (zfs_no_idmapping(mnt_userns, fs_userns))
+ struct user_namespace *owner = idmap_owner(mnt_userns);
+ if (zfs_no_idmapping(owner, fs_userns))
return (gid);
if (!zfs_is_init_userns(fs_userns))
gid = from_kgid(fs_userns, KGIDT_INIT(gid));
if (gid == (gid_t)-1)
return (gid);
- return (__kgid_val(make_kgid(mnt_userns, gid)));
+ return (__kgid_val(make_kgid(owner, gid)));
}
-static inline uid_t zfs_vfsuid_to_uid(struct user_namespace *mnt_userns,
+static inline uid_t zfs_vfsuid_to_uid(zidmap_t *mnt_userns,
struct user_namespace *fs_userns, uid_t uid)
{
- if (zfs_no_idmapping(mnt_userns, fs_userns))
+ struct user_namespace *owner = idmap_owner(mnt_userns);
+ if (zfs_no_idmapping(owner, fs_userns))
return (uid);
- uid = from_kuid(mnt_userns, KUIDT_INIT(uid));
+ uid = from_kuid(owner, KUIDT_INIT(uid));
if (uid == (uid_t)-1)
return (uid);
if (zfs_is_init_userns(fs_userns))
@@ -111,12 +116,13 @@ static inline uid_t zfs_vfsuid_to_uid(struct user_namespace *mnt_userns,
return (__kuid_val(make_kuid(fs_userns, uid)));
}
-static inline gid_t zfs_vfsgid_to_gid(struct user_namespace *mnt_userns,
+static inline gid_t zfs_vfsgid_to_gid(zidmap_t *mnt_userns,
struct user_namespace *fs_userns, gid_t gid)
{
- if (zfs_no_idmapping(mnt_userns, fs_userns))
+ struct user_namespace *owner = idmap_owner(mnt_userns);
+ if (zfs_no_idmapping(owner, fs_userns))
return (gid);
- gid = from_kgid(mnt_userns, KGIDT_INIT(gid));
+ gid = from_kgid(owner, KGIDT_INIT(gid));
if (gid == (gid_t)-1)
return (gid);
if (zfs_is_init_userns(fs_userns))