Thread (23 messages) 23 messages, 3 authors, 2025-11-04
STALE217d

[PATCH 14/16] act: use credential guards in acct_write_process()

From: Christian Brauner <brauner@kernel.org>
Date: 2025-11-03 11:27:49
Also in: cgroups, linux-cifs, linux-fsdevel, linux-nfs, linux-unionfs, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

Use credential guards for scoped credential override with automatic
restoration on scope exit.

Signed-off-by: Christian Brauner <brauner@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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help