[PATCH 14/16] act: use credential guards in acct_write_process()
Christian Brauner
brauner at kernel.org
Mon Nov 3 22:27:02 AEDT 2025
Use credential guards for scoped credential override with automatic
restoration on scope exit.
Signed-off-by: Christian Brauner <brauner at kernel.org>
---
kernel/acct.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/kernel/acct.c b/kernel/acct.c
index 61630110e29d..c1028f992529 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -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);
-
+ 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,6 @@ 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)
--
2.47.3
More information about the Linux-erofs
mailing list