Skip to content

Commit 545985d

Browse files
committed
coredump: use override credential guard
Use override credential guards for scoped credential override with automatic restoration on scope exit. Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-10-b447b82f2c9b@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 8ed3473 commit 545985d

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

fs/coredump.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,7 +1160,6 @@ void vfs_coredump(const kernel_siginfo_t *siginfo)
11601160
struct core_name cn;
11611161
const struct mm_struct *mm = current->mm;
11621162
const struct linux_binfmt *binfmt = mm->binfmt;
1163-
const struct cred *old_cred;
11641163
int argc = 0;
11651164
struct coredump_params cprm = {
11661165
.siginfo = siginfo,
@@ -1197,11 +1196,8 @@ void vfs_coredump(const kernel_siginfo_t *siginfo)
11971196
if (coredump_wait(siginfo->si_signo, &core_state) < 0)
11981197
return;
11991198

1200-
old_cred = override_creds(cred);
1201-
1202-
do_coredump(&cn, &cprm, &argv, &argc, binfmt);
1203-
1204-
revert_creds(old_cred);
1199+
scoped_with_creds(cred)
1200+
do_coredump(&cn, &cprm, &argv, &argc, binfmt);
12051201
coredump_cleanup(&cn, &cprm);
12061202
return;
12071203
}

0 commit comments

Comments
 (0)