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=1796418577; b=DivybF3lQGMV8D+hJ4NZ2ILqpGjE9B36oaZQMe93TUL+j8wKX1YIINy/+eMuqtOexWDQ o0GpL8rlOJOIkZMg5iyGkPn9oylrzCY7ohtb0k+K2RalRV4a3T+yj3pwMpIoGvMr409D4 xwiHJxRHHn3nx4q6l81LKnaH9mxympMhQ0iIUL31AWrJBBaFY+oPi5iVAmVLkegjwDLxf 1kh3/dDqiD2DB33ZlKsPYtBqcYUFcBtog5LMwb20nS65i/5KpyIbHY1Wo0zuhogqP+8Rs 7mO9MkwnVXeeKDYRnf9d5r8xLtwAi6iMUR7Z2fBcDEC9Up0chzbXF5IwLCcuGJ7TA3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796418577; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=UB9SlNaLF2SPCNxUDCkTnUjJMUJt12qSYfEvWUN7BEU=; b=XwR71khCaw1QOYPiru+3ZU8QeeTQY2GuD/pR1vrasV1oUX0D98Em8gdoG4XqZ9jFz6fp smu2jd6w8W/ICDyxRTn5ZM8/RcvpnQNJodibGHbe1hpYZiFITjAq4+98nCN5qfYbeJceu gHuFhts+PdTJ90wr4zq3ScQmGGEjh4csQGUHM1jYSwhgceJxruizbtXuz4UUeu1ShqBFe 5NSEy3BIN7ICfOYFWkO7SUQHUfQGgrLNZEea2tn4VVh8B8J+SFghNQaOEt9j5W5glLuUY MCeH6rvN3zrxbPCFyU7B25149KUohmZcKN9rjNvpPrX5S5gpB6KJ9+F1+ots/M6Z+9Q== 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=nknSD4XU; 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 91884606A336 for ; Fri, 4 Dec 2026 21:09:37 +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=nknSD4XU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 092421F00A11; Fri, 4 Dec 2026 21:09:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796418577; bh=UB9SlNaLF2SPCNxUDCkTnUjJMUJt12qSYfEvWUN7BEU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=nknSD4XU20YHi4/ROG76kBExyjgRJAgqM06syMIlEP5hiPFz+FbywzcVlFkr9lDhp SUBzuEJbFYScTKcRcbIAMt2mZQs2efvPXNWJI+qtKALRb31KNZVfOzpJ2g5C+x5mzR DaHlkvYJx9Rn6WiwCpAdVbJYdxlLEf3yKLjZtXMruSpgu0x4C6G3Yv5PsOzNd1nv0Q lFRKGR4Rw6+eG/PMEi18l71vL2UwrXBOU6LNhMMnjQumQjxMNxvJsWxQ1ZYklto4yV NwcCCa8zABvlN2Qr207xOB4jjbZDKNl9Rd7bH2uG4CUPojXaHdNTB2OBgQ+llZA5TH e6Y11NQPs8t4A== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH net 06/10] tcp: reject unreadable skbs on TCP-MD5 and TCP-AO Reply-To: sashiko-reviews@lists.linux.dev To: "Octavian Purdila" Cc: bpf@vger.kernel.org In-Reply-To: <961d3d81ff49e8dd5829a298c8d3a1a11a1e9bfc.1796329894.git.tavip@google.com> References: <961d3d81ff49e8dd5829a298c8d3a1a11a1e9bfc.1796329894.git.tavip@google.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 21:09:36 +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 2 potential issues to consider: - [Medium] tcp: TOCTOU race in tcp_sendmsg_locked() queues devmem skb with MD5/AO - [Low] tcp: missing mac_ctx zeroization on error path in tcp_ao_hash_skb() -- commit f478e860f2e25eba93883680fd5a2e35c2811f91 Author: Octavian Purdila tcp: reject unreadable skbs on TCP-MD5 and TCP-AO This commit rejects unreadable devmem skbs in TCP-MD5 and TCP-AO digest calculation and checks the hash helper errors on receive and reset paths. On transmit, it blocks devmem sends when a TCP-MD5 or TCP-AO key is active, rejects adding keys while unreadable skbs are queued, and guards __tcp_transmit_skb(). > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index 80de376a9d2ef..f0ab18b589872 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -1226,6 +1226,16 @@ int tcp_sendmsg_locked(struct sock *sk, struct msg= hdr *msg, size_t size) > /* 'common' sending to sendq */ > } > =20 > + if (unlikely(binding)) { > + struct tcp_key key; > + > + tcp_get_current_key(sk, &key); > + if (tcp_key_is_md5(&key) || tcp_key_is_ao(&key)) { > + err =3D -EOPNOTSUPP; > + goto out_err; > + } > + } > + > if (sockc_err) { > err =3D sockc_err; > goto out_err; [Severity: Medium] Can a concurrent setsockopt(TCP_MD5SIG) race with sk_stream_wait_memory() and bypass this check? tcp_sendmsg_locked() only checks tcp_get_current_key() once before the send loop, while sk_stream_wait_memory() drops and reacquires lock_sock(sk): CPU0 CPU1 tcp_sendmsg_locked() tcp_get_current_key() -> none sk_stream_wait_memory() release_sock(sk) setsockopt(TCP_MD5SIG) lock_sock(sk) tcp_md5_do_add() tcp_tx_has_unreadable_skb() -> false install MD5 key release_sock(sk) lock_sock(sk) queue unreadable devmem skb <-- bypasses check Once tcp_sendmsg_locked() queues the unreadable skb and returns success, __tcp_transmit_skb() rejects it with -EOPNOTSUPP without freeing it when clone_it is set. tcp_write_xmit() then breaks out leaving the skb stuck at tcp_send_head(sk), wedging TX until timeout, key removal, or socket close. Re-checking tcp_get_current_key() for binding after sk_stream_wait_memory() returns would close this window. [ ... ] > diff --git a/net/ipv4/tcp_ao.c b/net/ipv4/tcp_ao.c > index 857b8684e01d9..34c69dfcedd04 100644 > --- a/net/ipv4/tcp_ao.c > +++ b/net/ipv4/tcp_ao.c [ ... ] > @@ -726,7 +733,8 @@ int tcp_ao_hash_skb(unsigned short int family, > tcp_ao_hash_header(&mac_ctx, th, > !!(key->keyflags & TCP_AO_KEYF_EXCLUDE_OPT), > ao_hash, hash_offset, tcp_ao_maclen(key)); > - tcp_ao_hash_skb_data(&mac_ctx, skb, th->doff << 2); > + if (tcp_ao_hash_skb_data(&mac_ctx, skb, th->doff << 2)) > + goto clear_hash; > tcp_ao_mac_final(&mac_ctx, hash_buf); > =20 > memcpy(ao_hash, hash_buf, tcp_ao_maclen(key)); [Severity: Low] Does this error path leave mac_ctx unzeroized on the kernel stack? Jumping to clear_hash skips tcp_ao_mac_final(), which normally clears the stack-local mac_ctx holding derived TCP-AO traffic-key state. Zeroizing mac_ctx with memzero_explicit() under clear_hash would match the crypto library cleanup contract. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796329894.gi= t.tavip@google.com?part=3D6