diff options
| author | Christian Brauner <brauner@kernel.org> | 2025-11-03 00:12:47 +0100 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2025-11-04 12:36:21 +0100 |
| commit | 1ad5b411afc327ae50e569dbfa15774e0baefa68 (patch) | |
| tree | 0dbcb9b9afdbec28ea7741f11feaafa5e551c165 | |
| parent | 0f0e7cee3496cc053c7a1a15a428b585d6b7e897 (diff) | |
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>
| -rw-r--r-- | net/unix/af_unix.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index 768098dec231..68c94f49f7b5 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -1210,25 +1210,16 @@ static struct sock *unix_find_bsd(struct sockaddr_un *sunaddr, int addr_len, unix_mkname_bsd(sunaddr, addr_len); if (flags & SOCK_COREDUMP) { - const struct cred *cred; - struct cred *kcred; struct path root; - kcred = prepare_kernel_cred(&init_task); - if (!kcred) { - err = -ENOMEM; - goto fail; - } - task_lock(&init_task); get_fs_root(init_task.fs, &root); task_unlock(&init_task); - cred = override_creds(kcred); - err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path, - LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS | - LOOKUP_NO_MAGICLINKS, &path); - put_cred(revert_creds(cred)); + scoped_with_kernel_creds() + err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path, + LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS | + LOOKUP_NO_MAGICLINKS, &path); path_put(&root); if (err) goto fail; |
