Skip to content

Commit 1ad5b41

Browse files
committed
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>
1 parent 0f0e7ce commit 1ad5b41

1 file changed

Lines changed: 4 additions & 13 deletions

File tree

net/unix/af_unix.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,25 +1210,16 @@ static struct sock *unix_find_bsd(struct sockaddr_un *sunaddr, int addr_len,
12101210
unix_mkname_bsd(sunaddr, addr_len);
12111211

12121212
if (flags & SOCK_COREDUMP) {
1213-
const struct cred *cred;
1214-
struct cred *kcred;
12151213
struct path root;
12161214

1217-
kcred = prepare_kernel_cred(&init_task);
1218-
if (!kcred) {
1219-
err = -ENOMEM;
1220-
goto fail;
1221-
}
1222-
12231215
task_lock(&init_task);
12241216
get_fs_root(init_task.fs, &root);
12251217
task_unlock(&init_task);
12261218

1227-
cred = override_creds(kcred);
1228-
err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path,
1229-
LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS |
1230-
LOOKUP_NO_MAGICLINKS, &path);
1231-
put_cred(revert_creds(cred));
1219+
scoped_with_kernel_creds()
1220+
err = vfs_path_lookup(root.dentry, root.mnt, sunaddr->sun_path,
1221+
LOOKUP_BENEATH | LOOKUP_NO_SYMLINKS |
1222+
LOOKUP_NO_MAGICLINKS, &path);
12321223
path_put(&root);
12331224
if (err)
12341225
goto fail;

0 commit comments

Comments
 (0)