1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
3 * wrapper/user_namespace.h
5 * Copyright (C) 2019 Michael Jeanson <mjeanson@efficios.com>
9 #ifndef _LTTNG_WRAPPER_USER_NAMESPACE_H
10 #define _LTTNG_WRAPPER_USER_NAMESPACE_H
12 #include <lttng-kernel-version.h>
13 #include <linux/user_namespace.h>
16 #if LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(3, 5, 0)
18 #define lttng_current_xxuid(xxx) \
19 (from_kuid_munged(&init_user_ns, current_##xxx()))
21 #define lttng_current_vxxuid(xxx) \
22 (from_kuid_munged(current_user_ns(), current_##xxx()))
24 #define lttng_current_xxgid(xxx) \
25 (from_kgid_munged(&init_user_ns, current_##xxx()))
27 #define lttng_current_vxxgid(xxx) \
28 (from_kgid_munged(current_user_ns(), current_##xxx()))
31 uid_t
lttng_task_vuid(struct task_struct
*p
, struct user_namespace
*ns
)
36 kuid
= task_cred_xxx(p
, uid
);
37 uid
= from_kuid_munged(ns
, kuid
);
43 gid_t
lttng_task_vgid(struct task_struct
*p
, struct user_namespace
*ns
)
48 kgid
= task_cred_xxx(p
, gid
);
49 gid
= from_kgid_munged(ns
, kgid
);
56 #define lttng_current_xxuid(xxx) (current_##xxx())
58 #define lttng_current_vxxuid(xxx) \
59 (user_ns_map_uid(current_user_ns(), current_cred(), current_##xxx()))
61 #define lttng_current_xxgid(xxx) (current_##xxx())
63 #define lttng_current_vxxgid(xxx) \
64 (user_ns_map_gid(current_user_ns(), current_cred(), current_##xxx()))
67 uid_t
lttng_task_vuid(struct task_struct
*p
, struct user_namespace
*ns
)
72 * __task_cred requires the RCU readlock be held
75 uid
= user_ns_map_uid(ns
, __task_cred(p
), __task_cred(p
)->uid
);
82 gid_t
lttng_task_vgid(struct task_struct
*p
, struct user_namespace
*ns
)
87 * __task_cred requires the RCU readlock be held
90 gid
= user_ns_map_gid(ns
, __task_cred(p
), __task_cred(p
)->gid
);
98 #define lttng_current_uid() (lttng_current_xxuid(uid))
99 #define lttng_current_euid() (lttng_current_xxuid(euid))
100 #define lttng_current_suid() (lttng_current_xxuid(suid))
101 #define lttng_current_fsuid() (lttng_current_xxuid(fsuid))
102 #define lttng_current_gid() (lttng_current_xxgid(gid))
103 #define lttng_current_egid() (lttng_current_xxgid(egid))
104 #define lttng_current_sgid() (lttng_current_xxgid(sgid))
105 #define lttng_current_fsgid() (lttng_current_xxgid(fsgid))
107 #define lttng_current_vuid() (lttng_current_vxxuid(uid))
108 #define lttng_current_veuid() (lttng_current_vxxuid(euid))
109 #define lttng_current_vsuid() (lttng_current_vxxuid(suid))
110 #define lttng_current_vfsuid() (lttng_current_vxxuid(fsuid))
111 #define lttng_current_vgid() (lttng_current_vxxgid(gid))
112 #define lttng_current_vegid() (lttng_current_vxxgid(egid))
113 #define lttng_current_vsgid() (lttng_current_vxxgid(sgid))
114 #define lttng_current_vfsgid() (lttng_current_vxxgid(fsgid))
116 #endif /* _LTTNG_WRAPPER_USER_NAMESPACE_H */
This page took 0.031686 seconds and 4 git commands to generate.