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=1796381927; b=bOdwmsAQjkvfUQ6a29V5xwayRQ9AVsIUghLbXkZaFvwsHfsI8UD7PXzJYEBwEKRa1MxB TZJ34+Hfv1ALSqVY8hgzLEOrCRwuF9fEe2Xuqr0P61ZeXcp7GSnZzVQFydxd8JhWEC2Ch 4ewbBzF1cz6eoM1u1+r/p7fazOFWBq48OvUFw1JUMmFgqKQBRTzNzgLTXkvxo8BSabAXr XbRpBcn31hYYDQipJySC+fskHfbvSPhG23TCLpIkRdHJySEPfrPKHACU4Ct+EL0DeHNr4 YgM8t+Wi9v4pm5PfPwmV6XF4sUQ0dJ080oC4n3XSbQKIxB/4N/8vTCgwYJp5B9rZR3A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796381927; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=MPgRqrCClhDGnIt2qx5O5Lmxj7SrbY5xNbaGuLrlDjA=; b=h6kC7b0BU09KY04761dVxxjBobVPytNv15qUqN2/+Z/xVknCerNHH7c213lWx3WucFvY Nvcl88Vr0dVDyhuFYsU8//PUc+s87oMdbCD2JFZurmKc5WvD86CS8Uv8CEew2YBGyV4l/ v2j44pgnvOFMqoTz17VkrLnsmTudawbdxwoVSUolpFFFJ+Hx9TvlPLEfVCoZivHcrVG79 bXVQ+Pm9BAcoMcr99/vSdM7zQcPZ8HsuxQfkAtjcxSsaL04zMjCTc8tlv78JQKld0Ciu3 Lt5aPZuoyLEEJPXAM10+N6bDA6oFOavqzhMaMGPixbOnS3ozUj/hSTpLLv+2i1rwAXQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=N2QjG21t; 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 71B70606A322; Fri, 4 Dec 2026 10:58:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=N2QjG21t Received: by smtp.kernel.org (Postfix) with ESMTPSA id E02BA1F000C2; Fri, 4 Dec 2026 10:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796381927; bh=MPgRqrCClhDGnIt2qx5O5Lmxj7SrbY5xNbaGuLrlDjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=N2QjG21tsb8peScjm7Y3tSP20olsetNXrzB2MQUtDPkDMil2RyrL7oKyW0tQBdPna MF7SsPb7WT64WvBUf1DZjCMpcopKzviVsx+TXKLNNLnlr4ZuPYMAsM8DC0/2YVaf7D XGqwLUVmOUd+evBNr5gpyYedoEjCzMxrk++xFAeE= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thaison Phan , Eric Dumazet , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.18 192/703] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check() Date: Fri, 4 Dec 2026 19:01:31 +0900 Message-ID: <20261204100632.965331775@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100627.522266145@linuxfoundation.org> References: <20261204100627.522266145@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thaison Phan [ Upstream commit 7411fb1929075884648e9db0b9ec7e424c095185 ] Commit a3a128f611a9 ("inet: consolidate inet_csk_clone_lock()") moved the LOOPBACK4_IPV6 initialization for passive IPv6 TCP sockets from tcp_v6_syn_recv_sock() to tcp_v6_init_req(). IPv6 SYN cookie connections allocate a fresh request_sock without __GFP_ZERO and call tcp_v6_syn_recv_sock() without tcp_v6_init_req(), leaving ireq->ir_rmt_addr and ireq->ir_loc_addr uninitialized in cookie_v6_check(). inet_csk_clone_lock() then copies uninitialized slab bytes into sk_daddr, sk_rcv_saddr, and inet_saddr, exposing them to tracepoints and bpf_sock and causing inet_daddr != LOOPBACK4_IPV6 checks (such as IP_OPTIONS in do_ip_setsockopt()) to misclassify native IPv6 child sockets as IPv4-mapped. This was originally noticed via an out-of-tree socket hook observing inet_sk(sk)->inet_saddr != LOOPBACK4_IPV6 on KASAN test runs. KASAN enables SLUB_RCU_DEBUG by default, introducing an RCU grace period that prevents cookie_v6_check() from reusing the warm request_sock initialized during the initial SYN. Upstream, with tcp_syncookies=2, SLUB_RCU_DEBUG=y, and slub_debug=P, sock:inet_sock_set_state shows slab poison instead of 127.0.0.6: ... sock:inet_sock_set_state: family=AF_INET6 protocol=IPPROTO_TCP \ sport=59839 dport=41050 \ saddr=90.90.90.90 daddr=90.90.90.90 \ saddrv6=::1 daddrv6=::1 \ oldstate=TCP_LISTEN newstate=TCP_SYN_RECV Initialize ireq->ir_rmt_addr and ireq->ir_loc_addr to LOOPBACK4_IPV6 in cookie_v6_check() to match tcp_v6_init_req(). Tested against a QEMU reproducer checking inet_sock_set_state and IP_OPTIONS, as well as the packetdrill syncookie selftests. Fixes: a3a128f611a9 ("inet: consolidate inet_csk_clone_lock()") Signed-off-by: Thaison Phan Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/20261118210933.2477423-2-thaisonphan@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- net/ipv6/syncookies.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c index 4f6f0d751d6c5..e0758a6a6a8f7 100644 --- a/net/ipv6/syncookies.c +++ b/net/ipv6/syncookies.c @@ -17,6 +17,7 @@ #include #include #include +#include #define COOKIEBITS 24 /* Upper bits store count */ #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) @@ -205,6 +206,8 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb) ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr; ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr; + ireq->ir_rmt_addr = LOOPBACK4_IPV6; + ireq->ir_loc_addr = LOOPBACK4_IPV6; if (security_inet_conn_request(sk, skb, req)) { SKB_DR_SET(reason, SECURITY_HOOK); -- 2.53.0