summaryrefslogtreecommitdiff
path: root/net/unix
diff options
context:
space:
mode:
authorKuniyuki Iwashima <kuniyu@amazon.com>2024-06-20 23:56:22 +0300
committerPaolo Abeni <pabeni@redhat.com>2024-06-25 12:10:18 +0300
commite4bd881d987121dbf1a288641491955a53d9f8f7 (patch)
treeef2df0464c770cbbc8c3fef267286bea0ab0dca8 /net/unix
parentfaf489e6896d645a679d3d90a2d1d5d12c6b3e13 (diff)
downloadlinux-e4bd881d987121dbf1a288641491955a53d9f8f7.tar.xz
af_unix: Remove put_pid()/put_cred() in copy_peercred().
When (AF_UNIX, SOCK_STREAM) socket connect()s to a listening socket, the listener's sk_peer_pid/sk_peer_cred are copied to the client in copy_peercred(). Then, the client's sk_peer_pid and sk_peer_cred are always NULL, so we need not call put_pid() and put_cred() there. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'net/unix')
-rw-r--r--net/unix/af_unix.c9
1 files changed, 1 insertions, 8 deletions
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index d11664c2faad..3d0ace7ca017 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -772,9 +772,6 @@ static void update_peercred(struct sock *sk)
static void copy_peercred(struct sock *sk, struct sock *peersk)
{
- const struct cred *old_cred;
- struct pid *old_pid;
-
if (sk < peersk) {
spin_lock(&sk->sk_peer_lock);
spin_lock_nested(&peersk->sk_peer_lock, SINGLE_DEPTH_NESTING);
@@ -782,16 +779,12 @@ static void copy_peercred(struct sock *sk, struct sock *peersk)
spin_lock(&peersk->sk_peer_lock);
spin_lock_nested(&sk->sk_peer_lock, SINGLE_DEPTH_NESTING);
}
- old_pid = sk->sk_peer_pid;
- old_cred = sk->sk_peer_cred;
+
sk->sk_peer_pid = get_pid(peersk->sk_peer_pid);
sk->sk_peer_cred = get_cred(peersk->sk_peer_cred);
spin_unlock(&sk->sk_peer_lock);
spin_unlock(&peersk->sk_peer_lock);
-
- put_pid(old_pid);
- put_cred(old_cred);
}
static int unix_listen(struct socket *sock, int backlog)