mirror of https://github.com/torvalds/linux.git
act: use credential guards in acct_write_process()
Use credential guards for scoped credential override with automatic restoration on scope exit. Link: https://patch.msgid.link/20251103-work-creds-guards-simple-v1-14-a3e156839e7f@kernel.org Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
c5c92c624a
commit
5db84abd2a
|
|
@ -520,12 +520,10 @@ static void fill_ac(struct bsd_acct_struct *acct)
|
|||
static void acct_write_process(struct bsd_acct_struct *acct)
|
||||
{
|
||||
struct file *file = acct->file;
|
||||
const struct cred *cred;
|
||||
acct_t *ac = &acct->ac;
|
||||
|
||||
/* Perform file operations on behalf of whoever enabled accounting */
|
||||
cred = override_creds(file->f_cred);
|
||||
|
||||
scoped_with_creds(file->f_cred) {
|
||||
/*
|
||||
* First check to see if there is enough free_space to continue
|
||||
* the process accounting system. Then get freeze protection. If
|
||||
|
|
@ -538,8 +536,7 @@ static void acct_write_process(struct bsd_acct_struct *acct)
|
|||
__kernel_write(file, ac, sizeof(acct_t), &pos);
|
||||
file_end_write(file);
|
||||
}
|
||||
|
||||
revert_creds(cred);
|
||||
}
|
||||
}
|
||||
|
||||
static void do_acct_process(struct bsd_acct_struct *acct)
|
||||
|
|
|
|||
Loading…
Reference in New Issue