mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
cred: add kernel_cred() helper
Access kernel creds based off of init_task. This will let us avoid any direct access to init_cred. Link: https://patch.msgid.link/20251103-work-creds-init_cred-v1-2-cb3ec8711a6a@kernel.org Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
@@ -20,6 +20,8 @@
|
||||
struct cred;
|
||||
struct inode;
|
||||
|
||||
extern struct task_struct init_task;
|
||||
|
||||
/*
|
||||
* COW Supplementary groups list
|
||||
*/
|
||||
@@ -156,6 +158,11 @@ extern struct cred *prepare_exec_creds(void);
|
||||
extern int commit_creds(struct cred *);
|
||||
extern void abort_creds(struct cred *);
|
||||
extern struct cred *prepare_kernel_cred(struct task_struct *);
|
||||
static inline const struct cred *kernel_cred(void)
|
||||
{
|
||||
/* shut up sparse */
|
||||
return rcu_dereference_raw(init_task.cred);
|
||||
}
|
||||
extern int set_security_override(struct cred *, u32);
|
||||
extern int set_security_override_from_ctx(struct cred *, const char *);
|
||||
extern int set_create_files_as(struct cred *, struct inode *);
|
||||
|
||||
Reference in New Issue
Block a user