From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0DC7188CDC; Tue, 10 Sep 2024 10:43:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725964989; cv=none; b=pGrh9YDWe133SN8np466Phdiuid5g7AqoVnQWwrC7lKt7X00ui/JuxcYnvsFmn5C+mYXrSTullBBgDzsiwmTn4xNZfE3rU3i66GNLERh9yIf0iNhMrCd9o4zSqCP/V/S4aukkuT+N8cQYEYltNJ28tfZqm2VwA7VS91u8GyScNI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725964989; c=relaxed/simple; bh=ITsd97sE25Ha4wacZOwexsOXne8Dl7Im3AyumKV3Ays=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YXF/Ery/Oh+iPk6QYVOcrxRt8YINGZ1zDojrBacD8dN6wAs+AtLLksd9tC0+9xo5TDI43E/rv+Xxw0hgku0nHwj6RsPUD+FWGYtrAidEUd9zAl4/62qust5b3Gi4p3BXZ4fqK6s/dboKCZc2gNjbMjm/YiMBES/SGFmEdI/Qu/I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WrBT4RBJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WrBT4RBJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4C45DC4CEC3; Tue, 10 Sep 2024 10:43:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725964989; bh=ITsd97sE25Ha4wacZOwexsOXne8Dl7Im3AyumKV3Ays=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WrBT4RBJk1X+eEsmra0kfgfQ9EzJ5MzdwSHKSfIweLWwl+etf2Q1o2Ays9ACQjSGp PM7Q+Vr2XWMtXcF+YhFh8MCOoaM5KZZSlZ9I1pVHJz9S/GCGGT+m7KyKADv/fCpvaF gXb9gNDfxyysGe4gnKYmaWL9xn3oIST2qYrmvIwk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kuniyuki Iwashima , Paolo Abeni , Sasha Levin Subject: [PATCH 5.10 100/186] af_unix: Remove put_pid()/put_cred() in copy_peercred(). Date: Tue, 10 Sep 2024 11:33:15 +0200 Message-ID: <20240910092558.645591335@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092554.645718780@linuxfoundation.org> References: <20240910092554.645718780@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kuniyuki Iwashima [ Upstream commit e4bd881d987121dbf1a288641491955a53d9f8f7 ] 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 Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/unix/af_unix.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index e2ff610d2776..b7e9c1238516 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -603,9 +603,6 @@ static void init_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); @@ -613,16 +610,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) -- 2.43.0