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 CBB4C1E503D; Wed, 21 May 2025 14:51:04 +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=1747839064; cv=none; b=rxylDw/ksyqeICvE8OXOWLfBSvZmJ4/KinfB+xj7wxnStoTiuQOXE1NqGSP//T22aoSmcyqcPJkO76q5m5uDehFI/pBgf4rLyB/GFR9fRxWzbIJXOuS/jpreHIkfuLcEVu45+Z5H6yng78K+aA76vth41AKg2Mt81iNqfm4eym4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747839064; c=relaxed/simple; bh=PKUNOwIpuUE5YO5nXlI0AOnbmxAlCcv9+44QlYtduwY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qmo27YW6uQMNklZP8fQVF6rSHvL9jQPLbz9qfWA9oi+AVevPFyBGFdkZBKcC0eDlcX+npqx71qAg6jLIfv+eTbUgdMfRw9p1OrFwCPXh3FLUsp/rcMYiyH7ctFweH1J0O1eCDoeKP59/JIDNABvYpDNvPxybXo17HKMgVZMvoUg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=j8Uncq5h; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="j8Uncq5h" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73C61C4CEE4; Wed, 21 May 2025 14:51:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1747839064; bh=PKUNOwIpuUE5YO5nXlI0AOnbmxAlCcv9+44QlYtduwY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j8Uncq5heV8YgpaxK/ezZHH+Yuw74bNgNs6OnHGKTeX/HF2qh1AY+xtwRD5l/WSHg 47b7DjeZKLPRch+sw5LjP4DRInpPkH79onCjXrcXxZYnLxNi0dFGQutCnmQw6Iz2dQ 3vXueZbFxG+Bt7UuWwxUvBpPsM0MIZae5HqQXDvdRRuvo3J+sP3gu3MrHbLKwttSJW McrmjDA21W/WGPul607OjXPSatq/T77+AlmAxkbEIzhvpvamYnJhyI1XeW0/GtkT2Q 1jh9X4lraHX+AMj7iditTyp1ReVU3VXjFVpUqwX7L4q/ynxi5H2Rn7lE3tinM4h/XP yeAcuHtaLo4AA== From: Lee Jones To: lee@kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Kuniyuki Iwashima , Jens Axboe , Sasha Levin , Michal Luczaj , Rao Shoaib , Pavel Begunkov , linux-kernel@vger.kernel.org, netdev@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH v6.6 13/26] af_unix: Save listener for embryo socket. Date: Wed, 21 May 2025 14:45:21 +0000 Message-ID: <20250521144803.2050504-14-lee@kernel.org> X-Mailer: git-send-email 2.49.0.1112.g889b7c5bd8-goog In-Reply-To: <20250521144803.2050504-1-lee@kernel.org> References: <20250521144803.2050504-1-lee@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Kuniyuki Iwashima [ Upstream commit aed6ecef55d70de3762ce41c561b7f547dbaf107 ] This is a prep patch for the following change, where we need to fetch the listening socket from the successor embryo socket during GC. We add a new field to struct unix_sock to save a pointer to a listening socket. We set it when connect() creates a new socket, and clear it when accept() is called. Signed-off-by: Kuniyuki Iwashima Acked-by: Paolo Abeni Link: https://lore.kernel.org/r/20240325202425.60930-8-kuniyu@amazon.com Signed-off-by: Jakub Kicinski (cherry picked from commit aed6ecef55d70de3762ce41c561b7f547dbaf107) Signed-off-by: Lee Jones --- include/net/af_unix.h | 1 + net/unix/af_unix.c | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/include/net/af_unix.h b/include/net/af_unix.h index 37171943fb542..d6b755b254a17 100644 --- a/include/net/af_unix.h +++ b/include/net/af_unix.h @@ -83,6 +83,7 @@ struct unix_sock { struct path path; struct mutex iolock, bindlock; struct sock *peer; + struct sock *listener; struct unix_vertex *vertex; struct list_head link; unsigned long inflight; diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c index e54f54f9d9948..4d4c035ba626d 100644 --- a/net/unix/af_unix.c +++ b/net/unix/af_unix.c @@ -978,6 +978,7 @@ static struct sock *unix_create1(struct net *net, struct socket *sock, int kern, sk->sk_max_ack_backlog = READ_ONCE(net->unx.sysctl_max_dgram_qlen); sk->sk_destruct = unix_sock_destructor; u = unix_sk(sk); + u->listener = NULL; u->inflight = 0; u->vertex = NULL; u->path.dentry = NULL; @@ -1582,6 +1583,7 @@ static int unix_stream_connect(struct socket *sock, struct sockaddr *uaddr, newsk->sk_type = sk->sk_type; init_peercred(newsk); newu = unix_sk(newsk); + newu->listener = other; RCU_INIT_POINTER(newsk->sk_wq, &newu->peer_wq); otheru = unix_sk(other); @@ -1677,8 +1679,8 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags, bool kern) { struct sock *sk = sock->sk; - struct sock *tsk; struct sk_buff *skb; + struct sock *tsk; int err; err = -EOPNOTSUPP; @@ -1703,6 +1705,7 @@ static int unix_accept(struct socket *sock, struct socket *newsock, int flags, } tsk = skb->sk; + unix_sk(tsk)->listener = NULL; skb_free_datagram(sk, skb); wake_up_interruptible(&unix_sk(sk)->peer_wait); -- 2.49.0.1112.g889b7c5bd8-goog