Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sev-dev: use override credential guards

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-4-b447b82f2c9b@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>

+2 -8
+2 -8
drivers/crypto/ccp/sev-dev.c
··· 260 260 static struct file *open_file_as_root(const char *filename, int flags, umode_t mode) 261 261 { 262 262 struct path root __free(path_put) = {}; 263 - struct file *fp; 264 - const struct cred *old_cred; 265 263 266 264 task_lock(&init_task); 267 265 get_fs_root(init_task.fs, &root); ··· 270 272 return ERR_PTR(-ENOMEM); 271 273 272 274 cred->fsuid = GLOBAL_ROOT_UID; 273 - old_cred = override_creds(cred); 274 275 275 - fp = file_open_root(&root, filename, flags, mode); 276 - 277 - revert_creds(old_cred); 278 - 279 - return fp; 276 + scoped_with_creds(cred) 277 + return file_open_root(&root, filename, flags, mode); 280 278 } 281 279 282 280 static int sev_read_init_ex_file(void)