NetBSD Problem Report #60486
From www@netbsd.org Thu Jul 23 17:37:11 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange X25519 server-signature RSA-PSS (2048 bits)
client-signature RSA-PSS (2048 bits))
(Client CN "mail.netbsd.org", Issuer "YR2" (not verified))
by mollari.NetBSD.org (Postfix) with ESMTPS id C1A5B1A923B
for <gnats-bugs@gnats.NetBSD.org>; Thu, 23 Jul 2026 17:37:11 +0000 (UTC)
Message-Id: <20260723173710.8383C1A923C@mollari.NetBSD.org>
Date: Thu, 23 Jul 2026 17:37:10 +0000 (UTC)
From: campbell+netbsd@mumble.net
Reply-To: campbell+netbsd@mumble.net
To: gnats-bugs@NetBSD.org
Subject: tcp syncache leaks 4-byte kernel stack content
X-Send-Pr-Version: www-1.0
X-From4GNATS: "campbell+netbsd@mumble.net via gnats" <gnats-admin@NetBSD.org>
>Number: 60486
>Category: kern
>Synopsis: tcp syncache leaks 4-byte kernel stack content
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jul 23 17:40:00 +0000 2026
>Closed-Date: Thu Jul 30 13:11:23 +0000 2026
>Last-Modified: Thu Jul 30 13:11:23 +0000 2026
>Originator: Taylor R Campbell
>Release: current, 11, 10, 9, ...
>Organization:
The NetTCP Leakstacktion, Inc.
>Environment:
>Description:
The tcp syncache logic can leak a four-byte section of kernel
stack memory to the network.
877 syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th,
878 unsigned int toff, struct socket *so, struct mbuf *m, u_char *optp,
879 int optlen, struct tcp_opt_info *oi)
880 {
881 struct tcpcb tb, *tp;
...
897 #ifdef TCP_SIGNATURE
898 if (optp || (tp->t_flags & TF_SIGNATURE))
899 #else
900 if (optp)
901 #endif
902 {
903 tb.t_flags = tcp_do_rfc1323 ? (TF_REQ_SCALE|TF_REQ_TSTMP) : 0;
904 #ifdef TCP_SIGNATURE
905 tb.t_flags |= (tp->t_flags & TF_SIGNATURE);
906 #endif
907 tb.t_state = TCPS_LISTEN;
908 if (tcp_dooptions(&tb, optp, optlen, th, m, toff, oi) < 0)
909 return 0;
910 } else
911 tb.t_flags = 0;
...
938 sc->sc_timestamp = tb.ts_recent;
...
940 if (syn_cache_respond(sc) == 0) {
https://nxr.netbsd.org/xref/src/sys/netinet/tcp_syncache.c?r=1.7#863
Not all paths to
938 sc->sc_timestamp = tb.ts_recent;
initialize tb.ts_recent, so it may be uninitialized data from
the kernel stack. This may be then sent out on the wire in
syn_cache_respond:
1075 syn_cache_respond(struct syn_cache *sc)
1076 {
...
1115 /*
1116 * Create the IP+TCP header from scratch.
1117 */
1118 MGETHDR(m, M_DONTWAIT, MT_DATA);
...
1172 optp = (u_int8_t *)(th + 1);
...
1138 case AF_INET:
1139 ip = mtod(m, struct ip *);
...
1144 th = (struct tcphdr *)(ip + 1);
...
1149 case AF_INET6:
1150 ip6 = mtod(m, struct ip6_hdr *);
...
1156 th = (struct tcphdr *)(ip6 + 1);
...
1172 optp = (u_int8_t *)(th + 1);
...
1195 if (sc->sc_flags & SCF_TIMESTAMP) {
...
1202 u_int32_t *lp = (u_int32_t *)(optp);
...
=> 1205 *lp = htonl(sc->sc_timestamp);
...
1208 }
...
1337 case AF_INET:
1338 error = ip_output(m, sc->sc_ipopts, ro,
...
1348 error = ip6_output(m, NULL /*XXX*/, ro, 0, NULL,
https://nxr.netbsd.org/xref/src/sys/netinet/tcp_syncache.c?r=1.7#1068
Forwarded to us by Chris Jarrett-Davies <chrisjd@openai.com>.
>How-To-Repeat:
do a retransmitted SYN/ACK dance with syncache
>Fix:
memset(&tb, 0, sizeof(tb)) will rule it out, at some cost to
performance under load, since this is a ~800-byte structure.
Could try to be more selective about initialization, or about
when we set sc->sc_timestamp = tb.ts_recent.n
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->needs-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Thu, 23 Jul 2026 21:04:34 +0000
State-Changed-Why:
fixed in HEAD, needs pullup-11, pullup-10, pullup-9
State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Sat, 25 Jul 2026 19:49:53 +0000
State-Changed-Why:
pullup-11 #399 https://releng.netbsd.org/cgi-bin/req-11.cgi?show=399
pullup-10 #1319 https://releng.netbsd.org/cgi-bin/req-10.cgi?show=1319
pullup-9 #2041 https://releng.netbsd.org/cgi-bin/req-9.cgi?show=2041
From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60486 CVS commit: [netbsd-10] src/sys/netinet
Date: Tue, 28 Jul 2026 13:45:47 +0000
Module Name: src
Committed By: sborrill
Date: Tue Jul 28 13:45:47 UTC 2026
Modified Files:
src/sys/netinet [netbsd-10]: tcp_syncache.c
Log Message:
Pull up the following revisions(s) (requested by riastradh in ticket #1319):
sys/netinet/tcp_syncache.c: revision 1.8
tcp: Plug a 4-byte leak of kernel stack data through timestamps.
Addresses PR kern/60486
To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.6.2.1 src/sys/netinet/tcp_syncache.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Stephen Borrill" <sborrill@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/60486 CVS commit: [netbsd-9] src/sys/netinet
Date: Wed, 29 Jul 2026 10:33:05 +0000
Module Name: src
Committed By: sborrill
Date: Wed Jul 29 10:33:05 UTC 2026
Modified Files:
src/sys/netinet [netbsd-9]: tcp_input.c
Log Message:
Pull up the following revisions(s) (requested by riastradh in ticket #2041):
sys/netinet/tcp_input.c: patch
tcp: Plug a 4-byte leak of kernel stack data through timestamps.
Addresses PR kern/60486
To generate a diff of this commit:
cvs rdiff -u -r1.414.2.5 -r1.414.2.6 src/sys/netinet/tcp_input.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closed
State-Changed-By: riastradh@NetBSD.org
State-Changed-When: Thu, 30 Jul 2026 13:11:23 +0000
State-Changed-Why:
fixed in HEAD, pulled up to 11, 10, and 9
Pullup to 11 was missing the magic pattern, so here's the change:
https://mail-index.netbsd.org/source-changes/2026/07/30/msg163387.html
Module Name: src
Committed By: martin
Date: Thu Jul 30 10:50:15 UTC 2026
Modified Files:
src/sys/netinet [netbsd-11]: tcp_syncache.c
Log Message:
Pull up following revision(s) (requested by riastradh in ticket #399):
sys/netinet/tcp_syncache.c: revision 1.8
tcp syncache: Don't leak kernel stack data through timestamps.
kern/60486: tcp syncache leaks 4-byte kernel stack content
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.7.4.1 src/sys/netinet/tcp_syncache.c
>Unformatted:
(Contact us)
$NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.