mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
CRED: Detach the credentials from task_struct
Detach the credentials from task_struct, duplicating them in copy_process() and releasing them in __put_task_struct(). Signed-off-by: David Howells <dhowells@redhat.com> Acked-by: James Morris <jmorris@namei.org> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: James Morris <jmorris@namei.org>
This commit is contained in:
parent
b6dff3ec5e
commit
f1752eec61
11 changed files with 179 additions and 83 deletions
|
@ -158,4 +158,33 @@ do { \
|
|||
*(_gid) = current->cred->fsgid; \
|
||||
} while(0)
|
||||
|
||||
extern void __put_cred(struct cred *);
|
||||
extern int copy_creds(struct task_struct *, unsigned long);
|
||||
|
||||
/**
|
||||
* get_cred - Get a reference on a set of credentials
|
||||
* @cred: The credentials to reference
|
||||
*
|
||||
* Get a reference on the specified set of credentials. The caller must
|
||||
* release the reference.
|
||||
*/
|
||||
static inline struct cred *get_cred(struct cred *cred)
|
||||
{
|
||||
atomic_inc(&cred->usage);
|
||||
return cred;
|
||||
}
|
||||
|
||||
/**
|
||||
* put_cred - Release a reference to a set of credentials
|
||||
* @cred: The credentials to release
|
||||
*
|
||||
* Release a reference to a set of credentials, deleting them when the last ref
|
||||
* is released.
|
||||
*/
|
||||
static inline void put_cred(struct cred *cred)
|
||||
{
|
||||
if (atomic_dec_and_test(&(cred)->usage))
|
||||
__put_cred(cred);
|
||||
}
|
||||
|
||||
#endif /* _LINUX_CRED_H */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue