mirror of https://github.com/torvalds/linux.git
unix: don't copy creds
No need to copy kernel credentials. Link: https://patch.msgid.link/20251103-work-creds-init_cred-v1-8-cb3ec8711a6a@kernel.org Reviewed-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
parent
0f0e7cee34
commit
1ad5b411af
|
|
@ -1210,25 +1210,16 @@ static struct sock *unix_find_bsd(struct sockaddr_un *sunaddr, int addr_len,
|
||||||
unix_mkname_bsd(sunaddr, addr_len);
|
unix_mkname_bsd(sunaddr, addr_len);
|
||||||
|
|
||||||
if (flags & SOCK_COREDUMP) {
|
if (flags & SOCK_COREDUMP) {
|
||||||
const struct cred *cred;
|
|
||||||
struct cred *kcred;
|
|
||||||
struct path root;
|
struct path root;
|
||||||
|
|
||||||
kcred = prepare_kernel_cred(&init_task);
|
|
||||||
if (!kcred) {
|
|
||||||
err = -ENOMEM;
|
|
||||||
goto fail;
|
|
||||||
}
|
|
||||||
|
|
||||||
task_lock(&init_task);
|
task_lock(&init_task);
|
||||||
get_fs_root(init_task.fs, &root);
|
get_fs_root(init_task.fs, &root);
|
||||||
task_unlock(&init_task);
|
task_unlock(&init_task);
|
||||||
|
|
||||||
cred = override_creds(kcred);
|
scoped_with_kernel_creds()
|
||||||
err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path,
|
err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path,
|
||||||
LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS |
|
LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS |
|
||||||
LOOKUP_NO_MAGICLINKS, &path);
|
LOOKUP_NO_MAGICLINKS, &path);
|
||||||
put_cred(revert_creds(cred));
|
|
||||||
path_put(&root);
|
path_put(&root);
|
||||||
if (err)
|
if (err)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue