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=1796380148; b=EoyGHaFGQwlhwjqkFru68lBsKjZHFw6ZgKxsYEQ/pzeP2rXysbkZLn44R0+El9MTNMuC KKrPcpYotDdGvyv0g7xeA54Ri+7wIPvkPsqol+fnkCP4HJE2PqReREvJOnDlLTnQGCyow 6xD4/4g4rQE4UGaqpXqpjJMtGM1zQPCmO4HxEwKIEMtSmbQL1Gont+cqid/1D7fFzV1PC Cl503gnKvxWCtzH9MvIzPNFgohMxOoqMWrZqMn3L05hDDgk1UnCq9dwkDmsb2iWq595Dl Ul/h2rmLgyfrOy/lUfZ9A3MdEamdyZaVbYloaN6F3DTFabU4wzYsHGGEx5wICmyZ+/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380148; 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=m6sXJyncW5Hl6GbXgkZ0taHEWt7PyJDnc0p5iVxA6GU=; b=L77B9wi+LdrllJ3nyhxT1/QooXj1R4YmthD0tEZ654kWwzFPv8mQy+twHz3oL/5YCxfL sQ1rWTea0awNjnI2gt6T/GChKGYNNmc1k5g7zdvPOn9tf4Rr9nLnNDUX4oudfOhkD0Gvz DQSQxlrxrHSEfL7ukfKEsuySY3ziN4pW2/I9dL4fkezZIHjfWa85ihfhI5a/X0Jz/I/Lm bZ+PXtexNK0aJes0pzMkukZIkHVpJh4Pjvv6MzI3ney8EXUc+kQXKNwoXKxCEZ5Cv8i0F d19itjl1bidC+0B03cLJUHJa2/Ku7bkeTLNIzYDBjY/NjYsIRJX3Oq24TksYn1SkdRQ== 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=PTlICQqi; 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 24500606A335; Fri, 4 Dec 2026 10:29:07 +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=PTlICQqi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 53C781F00933; Fri, 4 Dec 2026 10:29:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380147; bh=m6sXJyncW5Hl6GbXgkZ0taHEWt7PyJDnc0p5iVxA6GU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=PTlICQqiS+nNzpEsyreOJ/1gLbn8kBJ4xSTEPY+hYCMXt8Inhl0nMKTYo6W5CMfaI hC0K5p1Otu0QzgSNH67dVpAjTw1+kMiiupJuW/5RUgMvTmrAc4lVlhpft8p00UFxMf zEaHy5wp2oJYYVTf1Xml0fk2F2F2ZtGTaSTiLuFA= 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 7.3 148/742] tcp: initialize ir_rmt_addr and ir_loc_addr in cookie_v6_check() Date: Fri, 4 Dec 2026 19:00:12 +0900 Message-ID: <20261204100639.051047652@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@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 7.3-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 b581cb1ee2e8a..b33011b71fff6 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