Article View: linux.kernel.netdev
Article #14668Re: [PATCH net] tcp: reject v4mapped source addresses in IPv6 SYN cookie ACKs
From: netdev-bot+sashiko
Date: Wed, 11 Nov 2026 19:02
Date: Wed, 11 Nov 2026 19:02
99 lines
11466 bytes
11466 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch closes only the v4mapped trigger.
--
tcp: reject v4mapped source addresses in IPv6 SYN cookie ACKs
This patch makes cookie_v6_check() reject ACKs whose IPv6 source address
is v4mapped, before any child socket is created. It matches the check
already done in tcp_v6_conn_request(). Before this, a SYN cookie child
with a v4mapped peer could be found by tcp_v4_err() and end up caching an
IPv4 rtable, which ip6_xmit() then used as an rt6_info.
> diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
> index b581cb1ee2e8a..6c5bb4bbd349c 100644
> --- a/net/ipv6/syncookies.c
> +++ b/net/ipv6/syncookies.c
> @@ -189,6 +189,12 @@ struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
> !th->ack || th->rst)
> goto out;
>
> + if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) {
> + __IP6_INC_STATS(net, NULL, IPSTATS_MIB_INHDRERRORS);
> + SKB_DR_SET(reason, IP_INHDR);
> + goto out_drop;
> + }
> +
> if (cookie_bpf_ok(skb)) {
> req = cookie_bpf_check(sk, skb);
> } else {
[Severity: Medium]
This closes the v4mapped case. The commit message also names the missing
IPv4 address initialization as part of the chain:
"cookie_v6_check() initializes the IPv6 address fields of the request
socket, but not its IPv4 address fields."
Is that still a problem for native IPv6 SYN cookie connections after this
patch? Further down in cookie_v6_check(), only the IPv6 fields are
written:
ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr;
ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr;
The normal SYN path sets the IPv4 fields in tcp_v6_init_req():
ireq->ir_rmt_addr = LOOPBACK4_IPV6;
ireq->ir_loc_addr = LOOPBACK4_IPV6;
On the cookie path, the request socket comes from a slab allocation that
is not zeroed:
cookie_tcp_check()
cookie_tcp_reqsk_alloc()
inet_reqsk_alloc()
reqsk_alloc_noprof()
kmem_cache_alloc_noprof(ops->slab, GFP_ATOMIC | __GFP_NOWARN)
Neither inet_reqsk_alloc() nor cookie_tcp_reqsk_init() sets skc_daddr or
skc_rcv_saddr. inet_csk_clone_lock() then copies those fields into the
child:
newsk->sk_daddr = ireq->ir_rmt_addr;
newsk->sk_rcv_saddr = ireq->ir_loc_addr;
newinet->inet_saddr = ireq->ir_loc_addr;
Since commit a3a128f611a965 ("inet: consolidate inet_csk_clone_lock()"),
tcp_v6_syn_recv_sock() no longer writes LOOPBACK4_IPV6 into the child.
So it looks like leftover slab bytes stay in inet_daddr, inet_rcv_saddr
and inet_saddr of every AF_INET6 child created from a SYN cookie.
Both ipv6_update_options() and do_ip_setsockopt(IP_OPTIONS) branch on
that value:
inet_sk(sk)->inet_daddr != LOOPBACK4_IPV6
Could this make icsk_ext_hdr_len and the MSS different for a SYN cookie
child than for a normally accepted IPv6 child? Could it also trigger KMSAN
uninit-value reports? The leftover bytes would also show up in the
inet_sock_set_state tracepoint and the BPF ip4 context fields.
Would it make sense to also set ir_rmt_addr and ir_loc_addr to
LOOPBACK4_IPV6 in cookie_v6_check(), as tcp_v6_init_req() does? That
would be in addition to the v4mapped rejection, not a replacement for it.
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/avFvW7nn7GIZmZ-a%40v4bel
Technical Details
Message-ID:
<179442373755.2199510.13127759467093413622@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361234-linux-kernel-netdev=dewy.ruReferences:
<avFvW7nn7GIZmZ-a@v4bel>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361234-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] tcp: reject v4mapped source addresses in IPv6 SYN cookie ACKs Date: Wed, 11 Nov 2026 19:02:17 +0000 Organization: Usenet Network Message-ID: <179442373755.2199510.13127759467093413622@kernel.org> References: <avFvW7nn7GIZmZ-a@v4bel> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="921448"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:gB65Up2Y29t5iiMfl9Omekpn+Wo= sha256:0NiMF0gAFjnu2Fn6g3nlQEySIgBiCh6PuGdfMLKVlys= sha1:Cb7W8N8MM8tBes+VVwzuROxDHFc= sha256:0F+qF56O6eXEYRwEW2+M8NHjsrLwTxVqAoLdlp6/o7E= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 6F586113F97; Wed, 11 Nov 2026 22:22:46 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uO7sLG2M3buY; Wed, 11 Nov 2026 22:22:42 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361234-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id BE137113F1A; Wed, 11 Nov 2026 22:22:33 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 3848B122E3F; Wed, 11 Nov 2026 19:03:18 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1794423740; b=BlYesNB2ohN0laPB3yDgV7Glu/kqMdVCCXz+ED1mEexRAVUIruiVYNcXgQdz4/AeJQ4V IiCMIuWxb0fdN0EhHFvgAQPoLY2JjMCYPC7GuDQn88cdAb38KL3KNw4eLhInX10N3lfpF Wd5pMg2veFK+34l2eVeBmXeBYlthGCdtlCNndp7utxM+xdzUy6OaLm2/toQAJEDCfM70O wkbyQbeIr3RC1F2KPpAZOoQEMSeMrfxzQyKh4LtSq60gSq2dAhsl4tne8eXup1dTRjuVv z8+AwrGtnDiyeK2cnJKZ6slJdv3sop2MB8IBi7VJch5Ms6SrG0IeXT6U2lOEJ1SSdgA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794423740; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=e22PuywE8UrFGA/QkpEbtslqBE+35TvWuYAk7qPJM74=; b=1dTvuBkBtuEQxOICEYHsqe6IcgHzrSr7iXH0vXXLh6S7D5pqp4mv4Vj96qtoB+/i9pRA Ag0rJE717HReeFWYQnFW4QhEmSXUW+f9j800khaYXrWxzNFSLfog0mipyPUFZ5BSNZ9qb juhOcJM2Yj8Q4dA8wjcGNFIPJ/n3Nf6jaCtcaf0I3Vc/JvN9iuJatVzGHU+y7tiha5w7o 8M5P0QFX4avEjRd1iHYEMNYFCwfFiNDxIbgiQjnEqb2WOgP7Wzn5AVFQ/9gpr2IH7xTYq KQZDx8EGtJiHGjoVjw8BU4t3dCT0nAKStmnwdYkhoseKx13T56477IxopFadRc7kaoQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Lx8ndOiX; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 13E0960A263F; Wed, 11 Nov 2026 19:02:20 +0000 (UTC) X-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=Lx8ndOiX X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794423739; b=GbFRlrjcviURQ+1ZunZxz4eOfhZ/fVL2HfftqvTAIVPFr3HpM77ZIDH7eC/XNHZg0HzV r6MwYarkbZfzFsgIdV0xmVXvm+hI9ChXBeZ50ARF86xID8JKyfITb2A792eC6cnReJKpl GUhtdZJlu6W8kg/68mt21SEMsJqNhR1PJ/aiPCZtMgcARA8ONQ1MCfhhv+468cBya1Hx3 9J+7mKVN04eEEmy/Vvvbs+4m+aRVXGx0BFTXXiexaDYdAy2srm8e+pnkwPUiw9dp8Mc7C hJY/hxbNGE72jpO9MX+d2ATdLmVThPvtL8mwGTf8zZeW3L2zSKABAcPrYQYa1eIdxCQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794423739; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=e22PuywE8UrFGA/QkpEbtslqBE+35TvWuYAk7qPJM74=; b=cUkWvWWk82LUqVEY7nb5CSdaB/eT4NXcNbqXZIiXqKTD83im9CsEbQFMyUx06xYTZF46 YVOG0ElvzHZHOXRP/e3Ulj9r1OwBV0Kyh2aWCUngU/P71FROX4v0xCK+abg0M+zbXMxUy uqPgbo1hr+EuM66YSjmfL+aAmVmRs3bKwuS8ZSYXDnuMKAndZkZlkf5VrwQ9MDqSu7AKL tgqAXKwVY71MXCD+XvKeHwX3uFGP+f3wtjKGwjbxs+RE5hjoTBueBsQ0HJ6/mUgvQ/AZk sA4Z20lNWYgJmispnoDJvKK7Rz0xVcQt3BOrpfLB5aZkxeDs1b9QZIWJYXe5Wee8y9Q== X-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=Lx8ndOiX; arc=none smtp.remote-ip=100.103.45.18 X-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 35BAA60A2627 for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 19:02:18 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 034911F00A09; Wed, 11 Nov 2026 19:02:17 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794423738; bh=e22PuywE8UrFGA/QkpEbtslqBE+35TvWuYAk7qPJM74=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Lx8ndOiXwW006PjU1I7F91iAdxDrSqMkmJBSEd+h8AJ0WDOj+LAViCU0j1bo34ECV jjbt6aHvAyzBV3E4oIFO5a4rUl/BLMz3RU/uV8zn8QtlBEXBaUYqkW5KKbsNHPWxDc ncP0rFOk3aEIOVHgP0KtIZA93PqqBjK+rYBp2IM3ptu2hqfZb/pjlqn/9LO5osAJnc mN6+Mg64dA9VRfa+2XFB2Kv/hZc2cWGO2/zP9Tth44KEXbcRyUJWhyqv8BWxShOzpi 9SFQ/v5RYbJUgvBatEDh+7VzXHn9mnU/DJyeefNm4Xmr6HEKJ4c45x6u8liNevkExw 7ovfCLuUxkhwA== X-Cc: edumazet@kernel.org, ncardwell@google.com, kuniyu@google.com, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, martineau@kernel.org, netdev@vger.kernel.org X-In-Reply-To: <avFvW7nn7GIZmZ-a@v4bel> X-sashiko-severity: Medium X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list