1b4d0d230SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2af777cd1SKees Cook /* Credentials management - see Documentation/security/credentials.rst
39e2b2dc4SDavid Howells *
49e2b2dc4SDavid Howells * Copyright (C) 2008 Red Hat, Inc. All Rights Reserved.
59e2b2dc4SDavid Howells * Written by David Howells ([email protected])
69e2b2dc4SDavid Howells */
79e2b2dc4SDavid Howells
89e2b2dc4SDavid Howells #ifndef _LINUX_CRED_H
99e2b2dc4SDavid Howells #define _LINUX_CRED_H
109e2b2dc4SDavid Howells
11b6dff3ecSDavid Howells #include <linux/capability.h>
12b2e1feafSAlexey Dobriyan #include <linux/init.h>
13b6dff3ecSDavid Howells #include <linux/key.h>
1460063497SArun Sharma #include <linux/atomic.h>
15d7700842SElena Reshetova #include <linux/refcount.h>
16ae2975bcSEric W. Biederman #include <linux/uidgid.h>
175b825c3aSIngo Molnar #include <linux/sched.h>
188703e8a4SIngo Molnar #include <linux/sched/user.h>
199e2b2dc4SDavid Howells
20b6dff3ecSDavid Howells struct cred;
213a3b7ce9SDavid Howells struct inode;
229e2b2dc4SDavid Howells
23b6dff3ecSDavid Howells /*
24b6dff3ecSDavid Howells * COW Supplementary groups list
25b6dff3ecSDavid Howells */
26b6dff3ecSDavid Howells struct group_info {
27d7700842SElena Reshetova refcount_t usage;
28b6dff3ecSDavid Howells int ngroups;
29c1f26493SHubert Jasudowicz kgid_t gid[];
303859a271SKees Cook } __randomize_layout;
31b6dff3ecSDavid Howells
32b6dff3ecSDavid Howells /**
33b6dff3ecSDavid Howells * get_group_info - Get a reference to a group info structure
34b6dff3ecSDavid Howells * @group_info: The group info to reference
35b6dff3ecSDavid Howells *
3686a264abSDavid Howells * This gets a reference to a set of supplementary groups.
3786a264abSDavid Howells *
3886a264abSDavid Howells * If the caller is accessing a task's credentials, they must hold the RCU read
3986a264abSDavid Howells * lock when reading.
40b6dff3ecSDavid Howells */
get_group_info(struct group_info * gi)4186a264abSDavid Howells static inline struct group_info *get_group_info(struct group_info *gi)
4286a264abSDavid Howells {
43d7700842SElena Reshetova refcount_inc(&gi->usage);
4486a264abSDavid Howells return gi;
4586a264abSDavid Howells }
46b6dff3ecSDavid Howells
47b6dff3ecSDavid Howells /**
48b6dff3ecSDavid Howells * put_group_info - Release a reference to a group info structure
49b6dff3ecSDavid Howells * @group_info: The group info to release
50b6dff3ecSDavid Howells */
51b6dff3ecSDavid Howells #define put_group_info(group_info) \
52b6dff3ecSDavid Howells do { \
53d7700842SElena Reshetova if (refcount_dec_and_test(&(group_info)->usage)) \
54b6dff3ecSDavid Howells groups_free(group_info); \
55b6dff3ecSDavid Howells } while (0)
56b6dff3ecSDavid Howells
572813893fSIulia Manda #ifdef CONFIG_MULTIUSER
582813893fSIulia Manda extern struct group_info *groups_alloc(int);
59b6dff3ecSDavid Howells extern void groups_free(struct group_info *);
602813893fSIulia Manda
612813893fSIulia Manda extern int in_group_p(kgid_t);
622813893fSIulia Manda extern int in_egroup_p(kgid_t);
634b09791bSOndrej Mosnáček extern int groups_search(const struct group_info *, kgid_t);
644b09791bSOndrej Mosnáček
654b09791bSOndrej Mosnáček extern int set_current_groups(struct group_info *);
664b09791bSOndrej Mosnáček extern void set_groups(struct cred *, struct group_info *);
674b09791bSOndrej Mosnáček extern bool may_setgroups(void);
684b09791bSOndrej Mosnáček extern void groups_sort(struct group_info *);
692813893fSIulia Manda #else
groups_free(struct group_info * group_info)702813893fSIulia Manda static inline void groups_free(struct group_info *group_info)
712813893fSIulia Manda {
722813893fSIulia Manda }
732813893fSIulia Manda
in_group_p(kgid_t grp)742813893fSIulia Manda static inline int in_group_p(kgid_t grp)
752813893fSIulia Manda {
762813893fSIulia Manda return 1;
772813893fSIulia Manda }
in_egroup_p(kgid_t grp)782813893fSIulia Manda static inline int in_egroup_p(kgid_t grp)
792813893fSIulia Manda {
802813893fSIulia Manda return 1;
812813893fSIulia Manda }
groups_search(const struct group_info * group_info,kgid_t grp)824b09791bSOndrej Mosnáček static inline int groups_search(const struct group_info *group_info, kgid_t grp)
834b09791bSOndrej Mosnáček {
844b09791bSOndrej Mosnáček return 1;
854b09791bSOndrej Mosnáček }
862813893fSIulia Manda #endif
87b6dff3ecSDavid Howells
88b6dff3ecSDavid Howells /*
89b6dff3ecSDavid Howells * The security context of a task
90b6dff3ecSDavid Howells *
91b6dff3ecSDavid Howells * The parts of the context break down into two categories:
92b6dff3ecSDavid Howells *
93b6dff3ecSDavid Howells * (1) The objective context of a task. These parts are used when some other
94b6dff3ecSDavid Howells * task is attempting to affect this one.
95b6dff3ecSDavid Howells *
96b6dff3ecSDavid Howells * (2) The subjective context. These details are used when the task is acting
97b6dff3ecSDavid Howells * upon another object, be that a file, a task, a key or whatever.
98b6dff3ecSDavid Howells *
99b6dff3ecSDavid Howells * Note that some members of this structure belong to both categories - the
100b6dff3ecSDavid Howells * LSM security pointer for instance.
101b6dff3ecSDavid Howells *
102b6dff3ecSDavid Howells * A task has two security pointers. task->real_cred points to the objective
103b6dff3ecSDavid Howells * context that defines that task's actual details. The objective part of this
104b6dff3ecSDavid Howells * context is used whenever that task is acted upon.
105b6dff3ecSDavid Howells *
106b6dff3ecSDavid Howells * task->cred points to the subjective context that defines the details of how
107b6dff3ecSDavid Howells * that task is going to act upon another object. This may be overridden
108b6dff3ecSDavid Howells * temporarily to point to another security context, but normally points to the
109b6dff3ecSDavid Howells * same context as task->real_cred.
110b6dff3ecSDavid Howells */
111b6dff3ecSDavid Howells struct cred {
112f8fa5d76SJens Axboe atomic_long_t usage;
113078de5f7SEric W. Biederman kuid_t uid; /* real UID of the task */
114078de5f7SEric W. Biederman kgid_t gid; /* real GID of the task */
115078de5f7SEric W. Biederman kuid_t suid; /* saved UID of the task */
116078de5f7SEric W. Biederman kgid_t sgid; /* saved GID of the task */
117078de5f7SEric W. Biederman kuid_t euid; /* effective UID of the task */
118078de5f7SEric W. Biederman kgid_t egid; /* effective GID of the task */
119078de5f7SEric W. Biederman kuid_t fsuid; /* UID for VFS ops */
120078de5f7SEric W. Biederman kgid_t fsgid; /* GID for VFS ops */
121b6dff3ecSDavid Howells unsigned securebits; /* SUID-less security management */
122b6dff3ecSDavid Howells kernel_cap_t cap_inheritable; /* caps our children can inherit */
123b6dff3ecSDavid Howells kernel_cap_t cap_permitted; /* caps we're permitted */
124b6dff3ecSDavid Howells kernel_cap_t cap_effective; /* caps we can actually use */
125b6dff3ecSDavid Howells kernel_cap_t cap_bset; /* capability bounding set */
12658319057SAndy Lutomirski kernel_cap_t cap_ambient; /* Ambient capability set */
127b6dff3ecSDavid Howells #ifdef CONFIG_KEYS
128b6dff3ecSDavid Howells unsigned char jit_keyring; /* default keyring to attach requested
129b6dff3ecSDavid Howells * keys to */
1305c7e372cSJann Horn struct key *session_keyring; /* keyring inherited over fork */
1313a50597dSDavid Howells struct key *process_keyring; /* keyring private to this process */
132b6dff3ecSDavid Howells struct key *thread_keyring; /* keyring private to this thread */
133b6dff3ecSDavid Howells struct key *request_key_auth; /* assumed request_key authority */
134b6dff3ecSDavid Howells #endif
135b6dff3ecSDavid Howells #ifdef CONFIG_SECURITY
1364ebd7651SPaul Moore void *security; /* LSM security */
137b6dff3ecSDavid Howells #endif
138b6dff3ecSDavid Howells struct user_struct *user; /* real user ID subscription */
1390093ccb6SEric W. Biederman struct user_namespace *user_ns; /* user_ns the caps and keyrings are relative to. */
140905ae01cSAlexey Gladkov struct ucounts *ucounts;
141b6dff3ecSDavid Howells struct group_info *group_info; /* supplementary groups for euid/fsgid */
142d7852fbdSLinus Torvalds /* RCU deletion */
143d7852fbdSLinus Torvalds union {
144d7852fbdSLinus Torvalds int non_rcu; /* Can we skip RCU deletion? */
145b6dff3ecSDavid Howells struct rcu_head rcu; /* RCU deletion hook */
146d7852fbdSLinus Torvalds };
1473859a271SKees Cook } __randomize_layout;
148b6dff3ecSDavid Howells
149f1752eecSDavid Howells extern void __put_cred(struct cred *);
150e0e81739SDavid Howells extern void exit_creds(struct task_struct *);
151f1752eecSDavid Howells extern int copy_creds(struct task_struct *, unsigned long);
152de09a977SDavid Howells extern const struct cred *get_task_cred(struct task_struct *);
153ee18d64cSDavid Howells extern struct cred *cred_alloc_blank(void);
154d84f4f99SDavid Howells extern struct cred *prepare_creds(void);
155a6f76f23SDavid Howells extern struct cred *prepare_exec_creds(void);
156d84f4f99SDavid Howells extern int commit_creds(struct cred *);
157d84f4f99SDavid Howells extern void abort_creds(struct cred *);
1583a3b7ce9SDavid Howells extern struct cred *prepare_kernel_cred(struct task_struct *);
1593a3b7ce9SDavid Howells extern int set_security_override(struct cred *, u32);
1603a3b7ce9SDavid Howells extern int set_security_override_from_ctx(struct cred *, const char *);
1613a3b7ce9SDavid Howells extern int set_create_files_as(struct cred *, struct inode *);
162d89b22d4SNeilBrown extern int cred_fscmp(const struct cred *, const struct cred *);
163d84f4f99SDavid Howells extern void __init cred_init(void);
164905ae01cSAlexey Gladkov extern int set_cred_ucounts(struct cred *);
165d84f4f99SDavid Howells
cap_ambient_invariant_ok(const struct cred * cred)16658319057SAndy Lutomirski static inline bool cap_ambient_invariant_ok(const struct cred *cred)
16758319057SAndy Lutomirski {
16858319057SAndy Lutomirski return cap_issubset(cred->cap_ambient,
16958319057SAndy Lutomirski cap_intersect(cred->cap_permitted,
17058319057SAndy Lutomirski cred->cap_inheritable));
17158319057SAndy Lutomirski }
17258319057SAndy Lutomirski
override_creds(const struct cred * override_cred)1736771e004SChristian Brauner static inline const struct cred *override_creds(const struct cred *override_cred)
17449dffdfdSVinicius Costa Gomes {
175*e04918dcSHerbert Xu return rcu_replace_pointer(current->cred, override_cred, 1);
17649dffdfdSVinicius Costa Gomes }
17749dffdfdSVinicius Costa Gomes
revert_creds(const struct cred * revert_cred)17851c0bcf0SChristian Brauner static inline const struct cred *revert_creds(const struct cred *revert_cred)
17949dffdfdSVinicius Costa Gomes {
180*e04918dcSHerbert Xu return rcu_replace_pointer(current->cred, revert_cred, 1);
18149dffdfdSVinicius Costa Gomes }
18249dffdfdSVinicius Costa Gomes
183d84f4f99SDavid Howells /**
18441e84562SMateusz Guzik * get_cred_many - Get references on a set of credentials
185f1752eecSDavid Howells * @cred: The credentials to reference
18641e84562SMateusz Guzik * @nr: Number of references to acquire
187f1752eecSDavid Howells *
18841e84562SMateusz Guzik * Get references on the specified set of credentials. The caller must release
18941e84562SMateusz Guzik * all acquired reference. If %NULL is passed, it is returned with no action.
19098870ab0SDavid Howells *
19198870ab0SDavid Howells * This is used to deal with a committed set of credentials. Although the
19298870ab0SDavid Howells * pointer is const, this will temporarily discard the const and increment the
19398870ab0SDavid Howells * usage count. The purpose of this is to attempt to catch at compile time the
19498870ab0SDavid Howells * accidental alteration of a set of credentials that should be considered
19598870ab0SDavid Howells * immutable.
196f1752eecSDavid Howells */
get_cred_many(const struct cred * cred,int nr)19741e84562SMateusz Guzik static inline const struct cred *get_cred_many(const struct cred *cred, int nr)
198f1752eecSDavid Howells {
1991c388ad0SPaul Menage struct cred *nonconst_cred = (struct cred *) cred;
200f06bc033SNeilBrown if (!cred)
201f06bc033SNeilBrown return cred;
202d7852fbdSLinus Torvalds nonconst_cred->non_rcu = 0;
203a6babf4cSChristian Brauner atomic_long_add(nr, &nonconst_cred->usage);
204a6babf4cSChristian Brauner return cred;
20541e84562SMateusz Guzik }
20641e84562SMateusz Guzik
20741e84562SMateusz Guzik /*
20841e84562SMateusz Guzik * get_cred - Get a reference on a set of credentials
20941e84562SMateusz Guzik * @cred: The credentials to reference
21041e84562SMateusz Guzik *
21141e84562SMateusz Guzik * Get a reference on the specified set of credentials. The caller must
21241e84562SMateusz Guzik * release the reference. If %NULL is passed, it is returned with no action.
21341e84562SMateusz Guzik *
21441e84562SMateusz Guzik * This is used to deal with a committed set of credentials.
21541e84562SMateusz Guzik */
get_cred(const struct cred * cred)21641e84562SMateusz Guzik static inline const struct cred *get_cred(const struct cred *cred)
21741e84562SMateusz Guzik {
21841e84562SMateusz Guzik return get_cred_many(cred, 1);
219f1752eecSDavid Howells }
220f1752eecSDavid Howells
get_cred_rcu(const struct cred * cred)22197d0fb23SNeilBrown static inline const struct cred *get_cred_rcu(const struct cred *cred)
22297d0fb23SNeilBrown {
22397d0fb23SNeilBrown struct cred *nonconst_cred = (struct cred *) cred;
22497d0fb23SNeilBrown if (!cred)
22597d0fb23SNeilBrown return NULL;
226f8fa5d76SJens Axboe if (!atomic_long_inc_not_zero(&nonconst_cred->usage))
22797d0fb23SNeilBrown return NULL;
228d7852fbdSLinus Torvalds nonconst_cred->non_rcu = 0;
22997d0fb23SNeilBrown return cred;
23097d0fb23SNeilBrown }
23197d0fb23SNeilBrown
232f1752eecSDavid Howells /**
233f1752eecSDavid Howells * put_cred - Release a reference to a set of credentials
234f1752eecSDavid Howells * @cred: The credentials to release
23541e84562SMateusz Guzik * @nr: Number of references to release
236f1752eecSDavid Howells *
237f1752eecSDavid Howells * Release a reference to a set of credentials, deleting them when the last ref
238f06bc033SNeilBrown * is released. If %NULL is passed, nothing is done.
23998870ab0SDavid Howells *
24098870ab0SDavid Howells * This takes a const pointer to a set of credentials because the credentials
24198870ab0SDavid Howells * on task_struct are attached by const pointers to prevent accidental
24298870ab0SDavid Howells * alteration of otherwise immutable credential sets.
243f1752eecSDavid Howells */
put_cred_many(const struct cred * _cred,int nr)24441e84562SMateusz Guzik static inline void put_cred_many(const struct cred *_cred, int nr)
245f1752eecSDavid Howells {
246c69e8d9cSDavid Howells struct cred *cred = (struct cred *) _cred;
247d84f4f99SDavid Howells
248f06bc033SNeilBrown if (cred) {
249f8fa5d76SJens Axboe if (atomic_long_sub_and_test(nr, &cred->usage))
250f1752eecSDavid Howells __put_cred(cred);
251f1752eecSDavid Howells }
252f06bc033SNeilBrown }
253f1752eecSDavid Howells
25441e84562SMateusz Guzik /*
25541e84562SMateusz Guzik * put_cred - Release a reference to a set of credentials
25641e84562SMateusz Guzik * @cred: The credentials to release
25741e84562SMateusz Guzik *
25841e84562SMateusz Guzik * Release a reference to a set of credentials, deleting them when the last ref
25941e84562SMateusz Guzik * is released. If %NULL is passed, nothing is done.
26041e84562SMateusz Guzik */
put_cred(const struct cred * cred)26141e84562SMateusz Guzik static inline void put_cred(const struct cred *cred)
26241e84562SMateusz Guzik {
26341e84562SMateusz Guzik put_cred_many(cred, 1);
26441e84562SMateusz Guzik }
26541e84562SMateusz Guzik
26686a264abSDavid Howells /**
2673b11a1deSDavid Howells * current_cred - Access the current task's subjective credentials
26886a264abSDavid Howells *
26932955148SAl Viro * Access the subjective credentials of the current task. RCU-safe,
27032955148SAl Viro * since nobody else can modify it.
27186a264abSDavid Howells */
27286a264abSDavid Howells #define current_cred() \
27327e4e436SDavid Howells rcu_dereference_protected(current->cred, 1)
27486a264abSDavid Howells
27586a264abSDavid Howells /**
276ae4b884fSJeff Layton * current_real_cred - Access the current task's objective credentials
277ae4b884fSJeff Layton *
278ae4b884fSJeff Layton * Access the objective credentials of the current task. RCU-safe,
279ae4b884fSJeff Layton * since nobody else can modify it.
280ae4b884fSJeff Layton */
281ae4b884fSJeff Layton #define current_real_cred() \
282ae4b884fSJeff Layton rcu_dereference_protected(current->real_cred, 1)
283ae4b884fSJeff Layton
284ae4b884fSJeff Layton /**
2853b11a1deSDavid Howells * __task_cred - Access a task's objective credentials
28686a264abSDavid Howells * @task: The task to query
28786a264abSDavid Howells *
2883b11a1deSDavid Howells * Access the objective credentials of a task. The caller must hold the RCU
28943e13cc1SOleg Nesterov * readlock.
29086a264abSDavid Howells *
2918f92054eSDavid Howells * The result of this function should not be passed directly to get_cred();
2928f92054eSDavid Howells * rather get_task_cred() should be used instead.
29386a264abSDavid Howells */
29486a264abSDavid Howells #define __task_cred(task) \
29543e13cc1SOleg Nesterov rcu_dereference((task)->real_cred)
29686a264abSDavid Howells
29786a264abSDavid Howells /**
2983b11a1deSDavid Howells * get_current_cred - Get the current task's subjective credentials
29986a264abSDavid Howells *
3003b11a1deSDavid Howells * Get the subjective credentials of the current task, pinning them so that
3013b11a1deSDavid Howells * they can't go away. Accessing the current task's credentials directly is
3023b11a1deSDavid Howells * not permitted.
30386a264abSDavid Howells */
30486a264abSDavid Howells #define get_current_cred() \
30586a264abSDavid Howells (get_cred(current_cred()))
30686a264abSDavid Howells
30786a264abSDavid Howells /**
30886a264abSDavid Howells * get_current_user - Get the current task's user_struct
30986a264abSDavid Howells *
31086a264abSDavid Howells * Get the user record of the current task, pinning it so that it can't go
31186a264abSDavid Howells * away.
31286a264abSDavid Howells */
31386a264abSDavid Howells #define get_current_user() \
31486a264abSDavid Howells ({ \
31586a264abSDavid Howells struct user_struct *__u; \
316638a8439SLinus Torvalds const struct cred *__cred; \
31732955148SAl Viro __cred = current_cred(); \
31886a264abSDavid Howells __u = get_uid(__cred->user); \
31986a264abSDavid Howells __u; \
32086a264abSDavid Howells })
32186a264abSDavid Howells
32286a264abSDavid Howells /**
32386a264abSDavid Howells * get_current_groups - Get the current task's supplementary group list
32486a264abSDavid Howells *
32586a264abSDavid Howells * Get the supplementary group list of the current task, pinning it so that it
32686a264abSDavid Howells * can't go away.
32786a264abSDavid Howells */
32886a264abSDavid Howells #define get_current_groups() \
32986a264abSDavid Howells ({ \
33086a264abSDavid Howells struct group_info *__groups; \
331638a8439SLinus Torvalds const struct cred *__cred; \
33232955148SAl Viro __cred = current_cred(); \
33386a264abSDavid Howells __groups = get_group_info(__cred->group_info); \
33486a264abSDavid Howells __groups; \
33586a264abSDavid Howells })
33686a264abSDavid Howells
33786a264abSDavid Howells #define task_cred_xxx(task, xxx) \
33886a264abSDavid Howells ({ \
339d84f4f99SDavid Howells __typeof__(((struct cred *)NULL)->xxx) ___val; \
34086a264abSDavid Howells rcu_read_lock(); \
34186a264abSDavid Howells ___val = __task_cred((task))->xxx; \
34286a264abSDavid Howells rcu_read_unlock(); \
34386a264abSDavid Howells ___val; \
34486a264abSDavid Howells })
34586a264abSDavid Howells
34686a264abSDavid Howells #define task_uid(task) (task_cred_xxx((task), uid))
34786a264abSDavid Howells #define task_euid(task) (task_cred_xxx((task), euid))
34821d1c5e3SAlexey Gladkov #define task_ucounts(task) (task_cred_xxx((task), ucounts))
34986a264abSDavid Howells
35086a264abSDavid Howells #define current_cred_xxx(xxx) \
35186a264abSDavid Howells ({ \
35232955148SAl Viro current_cred()->xxx; \
35386a264abSDavid Howells })
35486a264abSDavid Howells
35586a264abSDavid Howells #define current_uid() (current_cred_xxx(uid))
35686a264abSDavid Howells #define current_gid() (current_cred_xxx(gid))
35786a264abSDavid Howells #define current_euid() (current_cred_xxx(euid))
35886a264abSDavid Howells #define current_egid() (current_cred_xxx(egid))
35986a264abSDavid Howells #define current_suid() (current_cred_xxx(suid))
36086a264abSDavid Howells #define current_sgid() (current_cred_xxx(sgid))
36186a264abSDavid Howells #define current_fsuid() (current_cred_xxx(fsuid))
36286a264abSDavid Howells #define current_fsgid() (current_cred_xxx(fsgid))
36386a264abSDavid Howells #define current_cap() (current_cred_xxx(cap_effective))
36486a264abSDavid Howells #define current_user() (current_cred_xxx(user))
36521d1c5e3SAlexey Gladkov #define current_ucounts() (current_cred_xxx(ucounts))
36686a264abSDavid Howells
3677e6bd8faSEric W. Biederman extern struct user_namespace init_user_ns;
36847a150edSSerge E. Hallyn #ifdef CONFIG_USER_NS
36947a150edSSerge E. Hallyn #define current_user_ns() (current_cred_xxx(user_ns))
37047a150edSSerge E. Hallyn #else
current_user_ns(void)3710335695dSArnd Bergmann static inline struct user_namespace *current_user_ns(void)
3720335695dSArnd Bergmann {
3730335695dSArnd Bergmann return &init_user_ns;
3740335695dSArnd Bergmann }
37547a150edSSerge E. Hallyn #endif
37647a150edSSerge E. Hallyn
3773486740aSSerge E. Hallyn
37886a264abSDavid Howells #define current_uid_gid(_uid, _gid) \
37986a264abSDavid Howells do { \
38086a264abSDavid Howells const struct cred *__cred; \
38186a264abSDavid Howells __cred = current_cred(); \
38286a264abSDavid Howells *(_uid) = __cred->uid; \
38386a264abSDavid Howells *(_gid) = __cred->gid; \
38486a264abSDavid Howells } while(0)
38586a264abSDavid Howells
38686a264abSDavid Howells #define current_euid_egid(_euid, _egid) \
38786a264abSDavid Howells do { \
38886a264abSDavid Howells const struct cred *__cred; \
38986a264abSDavid Howells __cred = current_cred(); \
39086a264abSDavid Howells *(_euid) = __cred->euid; \
39186a264abSDavid Howells *(_egid) = __cred->egid; \
39286a264abSDavid Howells } while(0)
39386a264abSDavid Howells
39486a264abSDavid Howells #define current_fsuid_fsgid(_fsuid, _fsgid) \
39586a264abSDavid Howells do { \
39686a264abSDavid Howells const struct cred *__cred; \
39786a264abSDavid Howells __cred = current_cred(); \
39886a264abSDavid Howells *(_fsuid) = __cred->fsuid; \
39986a264abSDavid Howells *(_fsgid) = __cred->fsgid; \
40086a264abSDavid Howells } while(0)
40186a264abSDavid Howells
4029e2b2dc4SDavid Howells #endif /* _LINUX_CRED_H */
403