From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796324279; b=KD0Wv5rRIfkmlnGwIm1mZm8qYWXpOttkH90P9kPZTvWEBAWcqDLQnl7TYu+Cd5VMOnlV 2LL3ZZ+wBDHpAMPTxRHGlkS9jFefwn4skMSh5tIw1n2h14GCJrPebrd5yijafpbxT1NPF gkvL4MFtw85DGLYwXJ45Pky5/XClyT5y5+i+VLgf91ZSk3KBvaa/jSJjOad2GJvzZCMm0 7v39jqb7wOIJVDohI5eCHggtRNfrUnY2hnmaMJxSBpijz5JIz0zJukinn2ohiNVNT04oO mBn56caYrH0Im54xmrNJyOmuCNrf9TFEi/ygUJOyMeHgiWCURFcdq+PvexTHV2eFBfA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796324279; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=v6j+v/VjpStQHEZrOgB1WeMQjxrTfzRy4jMuqImez18=; b=L6ey7JZ4y0WI3mVYKx2ffqh8sGsLSeXEOS1AFtmAXj0BzfeZJtTlu8OeDSl8uRNVHRFU du0DIyWMBTZDfp5NjywBM1ZU/NQ6cHk7hGjj1spxVmgRFvBEObABykPbBMQpnJrRkFO4X aj/MeuOyaUHNCwadrS8WAijUu/aFI0ndrQUn2xNGMHvsOFis7X8CsglT5jELkkm+nN7Sp /ptQFTFRQOluZBRpORDs4rr6vlktzSLb5CPOfPdg2cFoXBr/sTGzQVF6Ns3k04YHEtgFR kQL16XnKJGbo1jtwUC4zik5qvBv0yg5jaJ/2d8eQ+mkzzwOeUozqwUdQ6x/upyc5d0w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZETjdeob; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4A3A606A337 for ; Thu, 3 Dec 2026 18:57:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZETjdeob Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74ECA1F0089B; Thu, 3 Dec 2026 18:57:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796324279; bh=v6j+v/VjpStQHEZrOgB1WeMQjxrTfzRy4jMuqImez18=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ZETjdeobnWItmp/bllJlFcmU3nAgtxzyKWn6YSB9L06LcOJoMWcLx8zlV8hJ9hG1h 7e5TAGw5v4GgDa05/40Zm0tMtu3puKgaJ7Cz+/uF1EJjEO8j+yuWDcntF5vMdv63Kn 4KuL5Q1DAJlzPAzdK9aEu861n58L9V9v9yVfVi0OKHiMNHnlGmF1Oi2WxJyYlIPUrN wDXH0lmFnPONb0jgR6Pjk11071/gsCpvzPmFAK1NHk7Dme75v1dbbC11B51c3xtaD/ JJLUE+qvRwuuAvAjyR/VjPlIQjQcz2oLw8oMhrs/6moYpZkB5/8n9RC0h6GneDazLZ JQ/tNU0GWStMA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net] net: init sk_refcnt, sk_state, sk_bpf_storage on clone Reply-To: sashiko-reviews@lists.linux.dev To: "Weiming Shi" Cc: bpf@vger.kernel.org In-Reply-To: <20261202185641.4035600-2-bestswngs@gmail.com> References: <20261202185641.4035600-2-bestswngs@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 18:57:59 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found no new issues in this patch, but noticed 1 related pre-existing issue it does not introduce: - [Critical] bpf, sockmap: race in tcp_bpf_clone() leaves psock callbacks on child socket [1] -- commit 2f699c239f62a4c51ffb60a012b53a93896cb087 Author: Weiming Shi net: init sk_refcnt, sk_state, sk_bpf_storage on clone This commit initializes sk_refcnt, sk_state, and sk_bpf_storage in sk_prot_alloc() when __GFP_ZERO is not set, and clears nsk->sk_bpf_storage in sock_copy() before security_sk_clone(). > diff --git a/net/core/sock.c b/net/core/sock.c > index 5ed63d2d8976f..15ffe7db9dc01 100644 > --- a/net/core/sock.c > +++ b/net/core/sock.c > @@ -2260,6 +2260,7 @@ static void sock_copy(struct sock *nsk, const struc= t sock *osk) > prot->obj_size - offsetof(struct sock, sk_dontcopy_end), > /* alloc is larger than struct, see sk_prot_alloc() */); > =20 > + bpf_sk_storage_init(nsk); [Severity: Critical] This problem wasn't introduced by this patch, but can a race between sock_copy() and sk_psock_drop() [1] leave sk_psock callbacks on a cloned child TCP socket? When a TCP socket is inserted into a sockmap or sockhash and later transitions to TCP_LISTEN (e.g., via tcp_disconnect() followed by inet_listen()), passive connection setup clones the listener in sk_clone_lock() without holding the listener socket lock or sk_callback_lock. sock_copy() copies sk_prot (before sk_dontcopy_begin) in the first memcpy() and sk_data_ready / sk_write_space (after sk_dontcopy_end) in the second unsafe_memcpy(), while sk_psock_drop() restores sk_prot before restoring the callbacks: CPU0 CPU1 sk_psock_drop() sk_clone_lock() sk_psock_restore_proto() sock_replace_proto() sock_copy() memcpy() // restored sk_prot unsafe_memcpy() // psock callbacks sk_psock_stop_verdict() sk->sk_data_ready =3D ... tcp_bpf_clone() // skips reset net/ipv4/tcp_bpf.c:tcp_bpf_clone() { struct proto *prot =3D newsk->sk_prot; if (!is_insidevar(prot, tcp_bpf_prots)) return; ... newsk->sk_data_ready =3D sock_def_readable; newsk->sk_write_space =3D sk_stream_write_space; } Because newsk->sk_prot is already restored to the base TCP protocol, tcp_bpf_clone() returns early without resetting newsk->sk_data_ready and newsk->sk_write_space. The child socket retains sk_psock_verdict_data_ready() without an attached sk_psock, stalling data delivery, and inserting that child into a sockmap saves sk_psock_verdict_data_ready() as psock->saved_data_ready, causing unbounded recursion and a kernel stack overflow when data arrives. [1] https://sashiko.dev/#/bug/linux-2fa20aa5-ab8d-4c5c-a262-b22090716944 --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202185641.4035= 600-2-bestswngs@gmail.com?part=3D1