Article View: linux.kernel.netdev
Article #13011[PATCH net] tcp: reject v4mapped source addresses in IPv6 SYN cookie ACKs
From: Hyunwoo Kim
Date: Mon, 09 Nov 2026 06:59
Date: Mon, 09 Nov 2026 06:59
106 lines
14036 bytes
14036 bytes
Commit dcc32f4f183a ("ipv6: weaken the v4mapped source check") removed
the v4mapped source address check from the IPv6 input path and moved
the TCP check to tcp_v6_conn_request(). The check is applied to SYN
packets handled by tcp_v6_conn_request(). However, an ACK that passes
SYN cookie validation is handled by cookie_v6_check() without passing
through tcp_v6_conn_request().
cookie_v6_check() initializes the IPv6 address fields of the request
socket, but not its IPv4 address fields. In the normal SYN cookie case,
inet_csk_clone_lock() copies those uninitialized IPv4 address fields
to the child socket.
The child is an AF_INET6 socket, but its remote IPv6 address is
v4mapped. sk_ehashfn() therefore uses the IPv4 address fields and TCP
ports to compute the hash. The child is then inserted into ehash with
that hash.
tcp_v4_err() uses __inet_lookup_established(), which does not exclude
AF_INET6 sockets. An ICMPv4 error can therefore find this child socket
if its quoted IPv4 tuple matches and the interface and sequence checks
pass.
For testing, the PoC used a server helper to construct an ACK with a
v4mapped source address that passed SYN cookie validation. Before
accept(), a matching ICMPv4 Fragmentation Needed message passed the
socket lookup and sequence checks in tcp_v4_err().
At that point sock_owned_by_user() returned false, so tcp_v4_err()
called tcp_v4_mtu_reduced() directly. inet_csk_rebuild_route() then
created an IPv4 rtable and cached it in the socket.
When the socket next transmitted over IPv6, ipv4_dst_check() returned
the cached rtable. ip6_xmit() then called ip6_dst_idev(), which
interpreted the rtable as struct rt6_info and read rt6i_idev. KASAN
reported a read of 8 bytes starting 32 bytes past the end of an rtable
object whose size was 176 bytes.
KASAN report:
BUG: KASAN: slab-out-of-bounds in ip6_xmit+0x119/0xb10
Read of size 8 at addr ffff88810356a9d0 by task target-server/79
...
Call Trace:
<TASK>
...
ip6_xmit+0x119/0xb10
...
inet6_csk_xmit+0x124/0x1d0
__tcp_transmit_skb+0xda0/0x1be0
...
tcp_write_xmit+0x985/0x2f80
__tcp_push_pending_frames+0x5a/0x150
tcp_sendmsg_locked+0xe7f/0x1b60
...
</TASK>
...
Allocated by task 0:
...
dst_alloc+0x52/0x250
rt_dst_alloc+0x33/0x170
ip_route_output_key_hash_rcu+0x6df/0xe20
ip_route_output_flow+0xab/0x160
inet_csk_rebuild_route+0x2a8/0x300
inet_csk_update_pmtu+0x85/0xb0
tcp_v4_mtu_reduced+0x52/0x170
tcp_v4_err+0x651/0x710
icmp_unreach+0x1c7/0x370
icmp_rcv+0x466/0x5a0
...
The buggy address belongs to the object at ffff88810356a900
which belongs to the cache rtable of size 176
The buggy address is located 32 bytes to the right of
allocated 176-byte region [ffff88810356a900, ffff88810356a9b0)
Reject v4mapped source addresses in cookie_v6_check() before creating
the child socket. As in tcp_v6_conn_request(), increment
IPSTATS_MIB_INHDRERRORS and drop the packet.
Fixes: dcc32f4f183a ("ipv6: weaken the v4mapped source check")
Cc: stable@vger.kernel.org
Assisted-by: LLM
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
---
net/ipv6/syncookies.c | 6 ++++++
1 file changed, 6 insertions(+)
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 {
--
2.43.0
Technical Details
Message-ID:
<avFvW7nn7GIZmZ-a@v4bel>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359053-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-359053-linux-kernel-netdev=dewy.ru
From: imv4bel@gmail.com (Hyunwoo Kim)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net] tcp: reject v4mapped source addresses in IPv6 SYN cookie
ACKs
Date: Mon, 9 Nov 2026 15:59:39 +0900
Organization: Usenet Network
Message-ID: <avFvW7nn7GIZmZ-a@v4bel>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: usenet.network;
logging-data="293902"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:RLtwJfEzQceMvGa7dOnm/LQknSU= sha256:FNgPRBVBzXA0R23XpCN2PdwuFb+660wtdQZmswySgcY=
sha1:uVrz6iQgMe4huQB7j4N/u3eX1p0= sha256:l1Wq/GFszhfCaFE4ZVRW7QtdA//8kCE/rY8H5WKaGdQ=
Content-Disposition: inline
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 C72A71136CB; Mon, 9 Nov 2026 10:00:04 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
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 V0qSm5OGq71z;
Mon, 9 Nov 2026 09:59:57 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-359053-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
by mail.dewy.ru (Postfix) with ESMTPS id 91BFD113461; Mon, 9 Nov 2026 09:59:49 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by sto.lore.kernel.org (Postfix) with ESMTP id 823D06056D3; Mon, 9 Nov 2026 06:59:48 +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=1794207586;
b=GsnirEo6DHLd9EA9/d+5oOuoZ0GPmVRVqUIYtoJm+I8tyOXSlIqThceJRZlG9FmX6KXM
Nhe4X/wg0iCJPaqkJlDskA+PgwUdyoJ8aihoOafwPY7Lp9ODLMYI8e1UdXYaFomOHdOs9
djhhwLTCCPVtQQZQgDrsWtNjHGkZ/l0tK5mtpRCZENtwt7ylP170DVXIbQqZENnsrDb/D
NC4HMAvG7LDFtXSHO200FJHpjm97u2CmhCBT/ypHhfoiEXZqYcfXV9eoOABC+XGl+MKJj
SfRmTG/a4nBJkyDVurXMLu8t3pixGPBSRlIh9qLk7Bwvy0XEvZmzDxl7vID0VPPqzQA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794207586;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:Date:From:To:Cc:Subject:Message-ID:X-Mailing-List:List-Id:
List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
Precedence:MIME-Version:Content-Type:Content-Disposition;
bh=aDlR4SU0MvcNZyb7xeT0WLCHbZ3cA560jShE4hSnDVE=;
b=sa++ur4Xb5hEk928BiGr7h0e0L9v4pPGe5ip17+3x83kXgQcbppCT2ZS+JTg9kdk/hNH
soRsNDcHU49wy98uFVFsaess56q7gTmAqp3ErlkMK++YfwoxnXcz78qiqaEfvqC50LmqF
5u4me0VG3nB0qqpcTWKJiG83tH74pdYvxe7nq53j21mgHqh5GMK9AhRnuX990rH2my/C1
b4SETyUNcoKLULnHtWU2UF9iMEs+BtCN18pH3BURsOOBjuBO9nEk/fKzRJWTNA6OKMY9X
dpXunmpyXF2fBmCElzSGUENkGSpSr4i5amHVIwoxWjbbbNkn7UDW+GYg4KwgbV/nhWw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tbRe44DH;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
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 6BB75606A32A;
Mon, 9 Nov 2026 06:59:46 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tbRe44DH
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.52
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1794207585;
b=U39NTyU9Kmcn16KeQJw6EIPd5pLv7p8iRx2YEpNm/yLDcCj222hqAMimrZBFZgQG7Ne5
EWT+IUY0qbXv+Zvv2pMq84Gu7tpyFa3T/K04GXdTiqI8GCFpljwGmQX+WXFl9SDrxCp3S
r3KCfzrVGWUC3AfGrAAPKI6m5wwFSxzif8qiBmP7fjx1Kczh5Job8Fzk98Eysh59Jde68
l2WqHk0BiQ2GNtbHlFWAOwwnWHvfj8gXqxp8kwa4LUgoBO0Z5H6ixyEN0/X3BkIizC0tX
uZgKqPA2dUXGbsQp15cff5ykneabwCLloKcilf+ILC61TjE+ZFt6qFDwv6C9cB/U16g==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1794207585;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:Date:From:To:Cc:
Subject:Message-ID:MIME-Version:Content-Type:Content-Disposition;
bh=aDlR4SU0MvcNZyb7xeT0WLCHbZ3cA560jShE4hSnDVE=;
b=vogr37WeWHnwmPGZJaraYXOIPxvoAGLakmwBIqOpV7HPXjqCUd96kAcQnvdy414Vj+m9
OS+nokCywdyL+SOfgEx5C8l+JTy7z4EfxZdjVPHkP4SHJlY2CHeJBSbgISt/sLgvfj5z/
9ylEaRSN78/RtOmt1pPJgcuWiSZUR9k525EjXw2NnUmC/CPaKAC0UdY0Ovq8+R/K2gU4M
D0SmxL5HC+ZwrXzAzfPx7hji6nuhr/5BZtaEhth7ahlWIs3rXwXmwme/lvgxtxVBAuvtm
ME85UjV6F/5I9sNHlCkhD4upVlKaMKG5CbuqZ5bRWJNI6HtuMBsaU8lfDPSLniR01lw==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=tbRe44DH;
arc=none smtp.remote-ip=74.125.82.52
X-Received: from mail-dl1-f52.google.com (mail-dl1-f52.google.com [74.125.82.52])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28418606A31C
for <netdev@vger.kernel.org>; Mon, 9 Nov 2026 06:59:44 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 28418606A31C
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dl1-f52.google.com with SMTP id a92af1059eb24-1931ff67a29so1502712c88.1
for <netdev@vger.kernel.org>; Sun, 08 Nov 2026 22:59:44 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1794207584; x=1794812384; darn=vger.kernel.org;
h=content-disposition:content-type:mime-version:message-id:subject:cc
:to:from:date:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=aDlR4SU0MvcNZyb7xeT0WLCHbZ3cA560jShE4hSnDVE=;
b=tbRe44DHoaKTBE0C72EgrLerFNS6Nxe+9whEvl6pBknPsrKJ+fq6Lc6GiI3aAqES0Q
rnvaCHHbc15ppGyUtmKctp9uxLQnGkuVtRmKriUh5IGVuFgTxL/rMh8sFqsj1SzErwGQ
hb2W4AP4alQnMTawTKG0aNW258uLL2eoCe+OzxOS773WuL5ZUEnesDn94R09U8MWjDYH
FOi5uZP/C2jE1tDRZWDaOmuY9/Z+v/+0Gs3kXcQVV42Vsia2aQVhKtMYuVDSqJrtmsZD
wuDGlqJ9zrEOGVA82iRQNp6/9G9ug9gqBjjJouojNHv70vz2qwvQiUhX2VCW6zmINYge
EqJw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1794207584; x=1794812384;
h=content-disposition:content-type:mime-version:message-id:subject:cc
:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=aDlR4SU0MvcNZyb7xeT0WLCHbZ3cA560jShE4hSnDVE=;
b=Jr0rhUPc0Op/UmCvVGUkfUbTZsjK5We78P74RX0UNmyBHvsTykZpM0MkynrsIFVvPs
JMQFoBRoTyKNLmSZIU2UdjhCmj2vJXyJer4VU/OzzZ286CrRtImokH70r3A9qaJL6yE7
QUchD58EHosWvN6s+foTJY1anBUUn8jcI3R53ab+LpnEiU6hKG0Vszb3nhtYfIeV+v3H
TBZ6QNliiQbowEqVwMkWVhLjOceFWT6LXq4gJTaHKp7teVTSKsJ3Mhpur5oTMzL4TGdL
vQ2Mw8mVyYSDo7CQMWDBvJTodDHxJFN8AxEs0Ul4G/FRAIgHxyoEw6ugaTCodhTxL5Tb
TKtA==
X-Gm-Message-State: APuU4Z8+v/WPFcnEDliltiroP75EOK12GhuASektAKG6teh6lxVhXN8C
PZb8FeWM+3fA8JSUSSvepVr5aXwMYmapRyKS/GauWL/V4NUxwmXesoYP
X-Gm-Gg: AYBFou0yV/B6HbuXeJQuaRxCLowpP8XEa4q7FPmrjgSkmuXtAwkpXWsIf/O9cFrPaIZ
/7kfqr2Qoy9BZdFMdT4snPzIKvCt6DTbBnW646Rag87QdmR8nbNug0lHSXrR6D62Pcjd4GXKpLg
9GlvseKU7JvhSjSYXmuXqlSQJz3lXYFhRNTTG68/fQlusHairVwD0GSusIy+1z4BFH8z8cW6UI1
Kd3dKkPhvNh83wXYjO3kFwmZeHDUgq6/cUDi4aV/pdmagWXzH16ZXVckrO9FxiOTyM2HrJKrr6F
NsKbP+Hhr22WSauGutafxp8Dixg8VYrYfu7p4unf5TqfIfHX1UzvPUojjd7CEkf0V9/mwJMt1Wv
vhD5uUMuafzh+1l0eiPyvqUEzuXRmqeKDeUJlEO13wr14bzHBpggXUfWZ6z8KteWRXUixZBYary
mbLR+quCnZ6v8bKUGlSkFu+vWm1tZcMJKJpnO3+9bNH+wamAPOo6IblR59bZqRqGyM77RRlFYBB
3ZlEGz+wYEvyAFEdPRSCBbxO9birZTKzZmei1vk11Y6/fEEn4zpIMs0zqMZMkDfGD4GIGfPISp4
x0UaGoy+PPH0a4AWrn8eSn758xmDJKWMqgoCdspQX5ju1vg=
X-Received: by 2002:a05:7023:a44:b0:16c:4eef:a526 with SMTP id a92af1059eb24-1b39fece490mr5565074c88.15.1794207583872;
Sun, 08 Nov 2026 22:59:43 -0800 (PST)
X-Received: from v4bel ([58.123.110.97])
by smtp.gmail.com with ESMTPSA id 5a478bee46e88-372669d2826sm11471893eec.29.2026.11.08.22.59.41
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Sun, 08 Nov 2026 22:59:43 -0800 (PST)
X-Cc: netdev@vger.kernel.org, imv4bel@gmail.com
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