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=1796019477; b=bxfrZWwPyZwsmNIzxhmoRDlVeSesmHs6Pmx+06G9w1SzqVLsrFzwv95T9x6YUDdPGeXI RjM5L50UIR0hn2tYNVmtsnhL+9T6pylfqYvXzrxU7P9JXAWPd7EQ8plyDQku/geYMzwii XWTAoDHaT9hyU8dZ0ibx+yzDA8ZmV7ODmHnHBt7g+k3iiADhkjbmnDiG6rPF3OWfeQFrx WkK7KTzU2nFLZETP9lhIhchoJdE1zOZDY2ff6GL1IlQYNjYWLQHtEGfC1I/C6hu6yLC/h grHigkxCmsdbHMJjjc9U4JvJ1U8CJjcisFXci4k2irEbN4Wv8UKT7PpmLuRrpwttGpA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796019477; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=zuaB64XpSG2vZMIY9Cs2bje7SPQUGGW4hdkrNVoQHoo=; b=LCC9YsEEZGNOB5O53dLFUHZ4TZ+3JjqSwsBb9bSLLxXnTS3+WQQVMO/UNuedri10H9cU Dg4QrJQi7oVfh9I/noH/ullK6uofIGHHNWwDcU1A5J//KXQQ1CkjFogmDxK9JqoA7J3OP nBEFB/BFDqY4hlyvSA2R2tSA8Ee+M2RGH11GHJt5mpVLHY1r8N82bOUemoeUDLlxQbNrd NtYnjEPGHpN2WEm8ec1A2cNGi4e+oz0VfC8PKUos4Yac6cmXko3YTymWqOWUEWP98eceI EDqGF2R1qzap0SgpnRClLGS+0avVh+ksdTrltXK3oTxA+3W6kB59IItlobWiKlqvPFg== 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=bAVV7Fh4; 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 35A27606A31C for ; Mon, 30 Nov 2026 06:17:56 +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=bAVV7Fh4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3FDCD1F00927; Mon, 30 Nov 2026 06:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796019476; bh=zuaB64XpSG2vZMIY9Cs2bje7SPQUGGW4hdkrNVoQHoo=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=bAVV7Fh40EpDaUEgjQjnDJQQH7D462v+NAik8wMIsAGq4VrmV1CTGAnl/+6x0jjxO NUVVbOBfC7Az/tl/j5VkheaBDpAPvdV5Q2UdeQS4QdwATJEpv7exyD3p+u/0XX0Qgx nqOT0aVyEkMP1qdlQtGavPRaSzhFSHeJ2LqfIihk/Hs4MVJFnlRl8yLFdLI178dbv8 UmBzasY/oOd83DY/BOPeYBm/MXcqqzzkkO3d2fNMSJnuN67bz0m3x2t3SKXm7cgDQB lF+pm2+OmFwKreBylNQcddN2BP6ph6tunTqu17FZxg6szzi9L9StOPajSPd1rjgU71 VdlKlfINaXqWA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf] bpf, sockmap: Don't replace a ULP's sk_prot when leaving a sockmap Reply-To: sashiko-reviews@lists.linux.dev To: "Sechang Lim" , bpf@vger.kernel.org In-Reply-To: <20261130055650.686483-1-rhkrqnwk98@gmail.com> References: <20261130055650.686483-1-rhkrqnwk98@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Mon, 30 Nov 2026 06:17:55 +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 1 potential issue to consider: - [Medium] bpf, sockmap: unrestored sk_write_space and tls_prots pollution on ULP socket -- commit 73c8b9838a60a20d7579f5fb528badbe18cba8d1 Author: Sechang Lim bpf, sockmap: Don't replace a ULP's sk_prot when leaving a sockmap This commit makes tcp_bpf_update_proto() return -EINVAL when restore is false and the socket has a ULP installed, preventing it from overwriting the ULP's sk->sk_prot when a socket is removed from a sockmap. > diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c > index 788ce08eef4d7..035894e5d9235 100644 > --- a/net/ipv4/tcp_bpf.c > +++ b/net/ipv4/tcp_bpf.c > @@ -810,6 +810,9 @@ int tcp_bpf_update_proto(struct sock *sk, struct sk_p= sock *psock, bool restore) > return 0; > } > =20 > + if (inet_csk_has_ulp(sk)) > + return -EINVAL; > + > if (sk->sk_family =3D=3D AF_INET6) { > if (tcp_bpf_assert_proto_ops(psock->sk_proto)) > return -EINVAL; [Severity: Medium] Does allowing a socket in a sockmap to attach the TLS ULP still leave sk->sk_write_space and tls_prots corrupted when the socket leaves the map? When a socket is added to a sockmap with a verdict or stream parser program, sk->sk_write_space is set to sk_psock_write_space and sk->sk_prot is set to tcp_bpf_prots. Attaching the TLS ULP via tls_init() leaves tx_conf at TLS_BASE (do_tls_setsockopt_conf() rejects sockets while sk_psock(sk) is set), so sk->sk_write_space stays sk_psock_write_space. When the psock is later dropped, the restore path in tcp_bpf_update_proto() calls tcp_update_ulp() -> tls_update(), which only writes ctx->sk_write_space =3D psock->saved_write_space and never restores sk->sk_write_space. Once sk->sk_user_data is cleared, sk->sk_write_space remains sk_psock_write_space with no psock, turning write-space wakeups into a permanent no-op. In addition, tls_init() calls tls_build_proto() while sk->sk_prot points to tcp_bpf_prots, which rebuilds the global tls_prots[ip_ver] table from tcp_bpf_prots and overwrites its callbacks with tcp_bpf_recvmsg_parser, sk_msg_is_readable, sock_map_destroy and tcp_bpf_ioctl. And if the socket was in two sockmaps (one with an sk_skb program and one without) before attaching TLS, removing it from the first map stops the verdict program via sk_psock_stop_verdict() and calls tcp_bpf_update_proto() with restore=3Dfalse; returning -EINVAL here leaves ctx->sk_proto and tls_prots using tcp_bpf_recvmsg_parser without a verdict program, causing subsequent recvmsg() calls to fail with -EAGAIN. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261130055650.6864= 83-1-rhkrqnwk98@gmail.com?part=3D1