lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251103-work-creds-guards-simple-v1-14-a3e156839e7f@kernel.org>
Date: Mon, 03 Nov 2025 12:27:02 +0100
From: Christian Brauner <brauner@...nel.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org, 
 linux-aio@...ck.org, linux-unionfs@...r.kernel.org, 
 linux-erofs@...ts.ozlabs.org, linux-nfs@...r.kernel.org, 
 linux-cifs@...r.kernel.org, samba-technical@...ts.samba.org, 
 cgroups@...r.kernel.org, netdev@...r.kernel.org, 
 Christian Brauner <brauner@...nel.org>
Subject: [PATCH 14/16] act: use credential guards in acct_write_process()

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

Signed-off-by: Christian Brauner <brauner@...nel.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ