mirror of
https://github.com/torvalds/linux.git
synced 2026-01-25 07:47:50 +00:00
sev-dev: use prepare credential guard
Use the prepare credential guard for allocating a new set of credentials. Link: https://patch.msgid.link/20251103-work-creds-guards-prepare_creds-v1-3-b447b82f2c9b@kernel.org Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
@@ -261,22 +261,22 @@ static struct file *open_file_as_root(const char *filename, int flags, umode_t m
|
||||
{
|
||||
struct path root __free(path_put) = {};
|
||||
struct file *fp;
|
||||
struct cred *cred;
|
||||
const struct cred *old_cred;
|
||||
|
||||
task_lock(&init_task);
|
||||
get_fs_root(init_task.fs, &root);
|
||||
task_unlock(&init_task);
|
||||
|
||||
cred = prepare_creds();
|
||||
CLASS(prepare_creds, cred)();
|
||||
if (!cred)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
cred->fsuid = GLOBAL_ROOT_UID;
|
||||
old_cred = override_creds(cred);
|
||||
|
||||
fp = file_open_root(&root, filename, flags, mode);
|
||||
|
||||
put_cred(revert_creds(old_cred));
|
||||
revert_creds(old_cred);
|
||||
|
||||
return fp;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user