Article View: linux.kernel.netdev
Article #26431[PATCH 6.1] tcp: fix NULL pointer dereference when restarting a Fast Open listener
From: Alexander Martyniuk
Date: Thu, 03 Dec 2026 14:42
Date: Thu, 03 Dec 2026 14:42
112 lines
15276 bytes
15276 bytes
From: Hyunwoo Kim <imv4bel@gmail.com>
commit aa40afa831ebfe45e40a23721711059f2ac584d4 upstream.
When a valid RST is received for a Fast Open child accepted before the
three-way handshake completes, reqsk_fastopen_remove() adds the
request_sock to the listener's RST list if the listener is in TCP_LISTEN.
An application can call shutdown(SHUT_RD) on a listener socket.
inet_csk_listen_stop() checks rskq_rst_head without holding
fastopenq.lock. If rskq_rst_head is NULL, it does not acquire the lock
and therefore does not synchronize with an insertion by
reqsk_fastopen_remove() after that function has passed the TCP_LISTEN
check.
The more likely outcome of this race, even without a subsequent
listen(), is a leak. If reqsk_fastopen_remove() inserts a request_sock
after inet_csk_listen_stop() observes an empty list and returns, the
request_sock is stranded in rskq_rst_head and keeps a reference on the
listener. The socket is already in TCP_CLOSE, so a subsequent close()
does not call inet_csk_listen_stop() again.
If listen() is called again on the same socket before the delayed list
insertion, the insertion can overlap the queue initialization in
reqsk_queue_alloc(). If it occurs after rskq_rst_head is set to NULL but
before rskq_rst_tail is set to NULL, rskq_rst_head points to the
request_sock while rskq_rst_tail is NULL.
When a valid RST is later received for another accepted Fast Open child,
rskq_rst_head is not NULL, so reqsk_fastopen_remove() attempts to write
the request_sock pointer to rskq_rst_tail->dl_next while rskq_rst_tail is
NULL. KASAN reports:
BUG: KASAN: null-ptr-deref in reqsk_fastopen_remove+0x147/0x210
Write of size 8 at addr 0000000000000088 by task swapper/3/0
...
Call Trace:
<IRQ>
...
reqsk_fastopen_remove+0x147/0x210
tcp_check_req+0xa70/0x1060
...
tcp_rcv_state_process+0x1cb/0x2ae0
...
tcp_v4_do_rcv+0x1fe/0x740
tcp_v4_rcv+0x1744/0x2070
...
ip_protocol_deliver_rcu+0x5c/0x280
ip_local_deliver_finish+0x171/0x330
ip_local_deliver+0x107/0x370
...
</IRQ>
To widen the race window, the issue was reproduced after adding
mdelay(3000) immediately after reqsk_fastopen_remove() checks that the
listener is in TCP_LISTEN and immediately after reqsk_queue_alloc() sets
rskq_rst_head to NULL.
Make inet_csk_listen_stop() acquire fastopenq.lock regardless of the
value of rskq_rst_head and detach the list while holding the lock. With
this synchronization, reqsk_fastopen_remove() either inserts the
request_sock before inet_csk_listen_stop() acquires the lock, in which
case inet_csk_listen_stop() reclaims it, or sees that the listener is
not in TCP_LISTEN and does not insert anything.
Fixes: 0536fcc039a8 ("tcp: prepare fastopen code for upcoming listener changes")
Cc: stable@vger.kernel.org
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@google.com>
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Link: https://patch.msgid.link/avMkfJrXhCFXn8M_@v4bel
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Alexander Martyniuk <alexevgmart@gmail.com>
---
Backport fix for CVE-2026-142949
net/ipv4/inet_connection_sock.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 3ade0dd5cdbc..00102d364a42 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -1488,17 +1488,15 @@ void inet_csk_listen_stop(struct sock *sk)
cond_resched();
}
- if (queue->fastopenq.rskq_rst_head) {
- /* Free all the reqs queued in rskq_rst_head. */
- spin_lock_bh(&queue->fastopenq.lock);
- req = queue->fastopenq.rskq_rst_head;
- queue->fastopenq.rskq_rst_head = NULL;
- spin_unlock_bh(&queue->fastopenq.lock);
- while (req != NULL) {
- next = req->dl_next;
- reqsk_put(req);
- req = next;
- }
+ /* Free all the reqs queued in rskq_rst_head. */
+ spin_lock_bh(&queue->fastopenq.lock);
+ req = queue->fastopenq.rskq_rst_head;
+ queue->fastopenq.rskq_rst_head = NULL;
+ spin_unlock_bh(&queue->fastopenq.lock);
+ while (req != NULL) {
+ next = req->dl_next;
+ reqsk_put(req);
+ req = next;
}
WARN_ON_ONCE(sk->sk_ack_backlog);
}
--
2.43.0
Technical Details
Message-ID:
<20261203144253.831815-1-alexevgmart@gmail.com>Path:
mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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-376669-linux-kernel-netdev=dewy.ruShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srl.newsdeef.eu.MISMATCH!feed-eu-txt.newsdeef.eu!feed-eu-ch.newsdeef.eu!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-376669-linux-kernel-netdev=dewy.ru
From: alexevgmart@gmail.com (Alexander Martyniuk)
Newsgroups: linux.kernel.netdev
Subject: [PATCH 6.1] tcp: fix NULL pointer dereference when restarting a Fast Open listener
Date: Thu, 3 Dec 2026 17:42:52 +0300
Organization: Usenet Network
Message-ID: <20261203144253.831815-1-alexevgmart@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="2516965"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:vaUnvuKKhdmJ28p3NKluhVBi+ts= sha256:pcity4tXBCxXABBDA5h/ltT07g8I+I10sQ/+ea1Pyuc=
sha1:mtsmdx+A3iMAxtWWFVTlFSQtIsw= sha256:Ry40PIM9aW84I6S46h9Gv3NrjVxnXFXiCBiyu0P4O0M=
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 2F6F3117985; Thu, 3 Dec 2026 17:43:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.397
X-Spam-Status: No, score=-3.397 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.001, 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 uP4YoVKcgNgt;
Thu, 3 Dec 2026 17:43:18 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376669-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 1209111796D; Thu, 3 Dec 2026 17:43:09 +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 B3A666032E8; Thu, 3 Dec 2026 14:43:08 +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=1796308987;
b=31rt6Q7HQoPdn9wopEO3O8Vu/gagniytATiTEFHxNZBuBvI+JgbBjKx6347KNGBrpsiO
CIPAZHjN2wX74E9DskNPBx77/mS5KRAu42nzUpWkjU38f60y20kI50RVYb7AGYmBxj+fU
Q0g9gAPiQcNqQRyB6pQQhagj3fv/+iRmYDDtNBV55mDAuz45/twSZEkjHVKMCseQoTV5c
Xmp7hjsERrTw2g/dCqp16L/jSbS9SrNx/WToNYaoEoEe2ktHMTMmV7LlVuOzQcKQQ8T0I
7FUSnOyJmvKwYyrymwVZB76ujNtKQHpz1M4yZStkutFIzC4dMuep1hvMtnTKKN0IGoQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796308987;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:Date:Message-ID:
X-Mailer:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=fkQiyVF+i+e2AERSx9XhCzFokuJ1AUVIhozYxtneuAY=;
b=MX58fzl+5hXYPlSC9g79fKVmwcfp8J/aC/JlhX9FfOdaX8mMKO4rFC0P5jVvpF3mwPz3
SpgDGKs5LqPyQxkjZWBDKRQWYp2TmMM8tZvudg58PdBVLPWjQLbgGFOMDc1+IVXwuGDyZ
d9O+ideC57xb6ys2Oi/CIQHcJuQ5Mxhq1mOyeigah9UrLcZGanYlmdxG+OR7T8OnTjcT8
EzkT5CD148L9veAY+MwUogNogdTD6Xvm3/Nkij6nHWaUolmffBAlintvfYisc/dKMKaXY
6kRXV4LpE64iFENsncBgImGhfqrDk6n4p85+aOXhJEzK8b7tvPPD3tZtt9Nh9RrGcLQ==
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=yu4CpAdv;
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 EF601606A33B;
Thu, 3 Dec 2026 14:43:06 +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=yu4CpAdv
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1796308986;
b=ORrLchGViQUKijMU8zherRiKOErVDgip0cUBNXJ0l5c4nCNrxAHi+YjKy7aryH0oJlQd
bkipeY4qAcIo1e/Ghi7Cu/nwlYl+UCweD8rqjGKoZ7O+2A4rjjEkRAE2ayR3K783vZDCT
pe8REYAFKt/5IfrF/nC5NIsj4itN7gqGwMyEApP1sYgHJ7BV/tg+61X20wq7wGkEaIaLe
fZMwtst7r50EB9IpgULl2cz+O/1gy8yfhIeAj7ltCYqjyUeE7kuI+yhdcY8SfiXZ8beOf
zZmBzXnYIoxDvDah+6vke6SEseprxU5lafZYRzng8cwHaNDPmznNWMzq+NE6Tj4aZmw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1796308986;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version:
Content-Transfer-Encoding;
bh=fkQiyVF+i+e2AERSx9XhCzFokuJ1AUVIhozYxtneuAY=;
b=rDyLLI/ll7d2sN5wZ+tUQctf6vT00Ztc5fgytSRqnF4aB7sDofSXhPR/k1+JV208Q+jz
FbVhY5lJJvBVdAS+j0eD35WdheICS/HHmX8OOiG5pSRqaJZ0XlFL6bNQtPEsAHMN760FL
7LcMMlgOHA2WKaJVorGKipVQJUNtj7Gmp6dOL7ugNgYmtkX1t8pzuh2A3E2OI6KMfbbp1
u2FVsJ+Xu2sCa289nwucw0YjvcqT4IM0BONIhqDAioa2gZEl7w5RHGBm7Y7HJf3j6iE9g
qBP876VJgnH7071aFesSgBgz67XiHIrBLK63whjKmHbTRO4/xb2ggTJ/eyT/j/Gat3w==
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=yu4CpAdv;
arc=none smtp.remote-ip=209.85.221.45
X-Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45])
(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 78A85606A32D
for <netdev@vger.kernel.org>; Thu, 3 Dec 2026 14:43:05 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78A85606A32D
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-wr1-f45.google.com with SMTP id ffacd0b85a97d-4cf418d85bbso622135f8f.2
for <netdev@vger.kernel.org>; Thu, 03 Dec 2026 06:43:05 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1796308984; x=1796913784; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=fkQiyVF+i+e2AERSx9XhCzFokuJ1AUVIhozYxtneuAY=;
b=yu4CpAdvA1W1KbZ8BYqfXEiBGHh8WwwFuJpW8F5wK+ECu+zjo/Zi1rItSAK37FMniU
eeIr+DQdWrAndXhKWpi05P4U3MPVLYewwPoHmH1+FCJ2DE+OId2Fu1axeOW1fDZK5uNT
gBbfcmC4rcqkmZYwlEARjtHcWxouYabyeJg65HEN/FAyUSI7o96hQSwfgQc/i0eylPBo
PqF11R+8WtBK418x2USKE0bRD4mfefHb34gTETviNSMtQQJ8Ucj7QDVtSu3mK+7GscwP
H2cmCmm4YgJiF04Mz8WKmn1X8JOMU+JMbNzCy6YpYG1KmLQVLJyPNRm1KvVfgBBpVM9k
jcrw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1796308984; x=1796913784;
h=content-transfer-encoding:mime-version:message-id:date:subject:cc
:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=fkQiyVF+i+e2AERSx9XhCzFokuJ1AUVIhozYxtneuAY=;
b=lEO+5VXSoALTpntORY2swqU6zQs8Tx0lf7ShZzFl20488P6s1g9ZxGpYPXA82ALnY3
jjNdn6aEhnyilhWqqpZRoD21ve2TIEsVLKxEWjBiou4qifhoBJ0MXY2fUlh3LGSKl4vk
O8Jmlzr7v4aJSACPffGqd49DB34eJ34Z3twiCBmyCGyQePw10zmqgQHp6hnhhAXEmzn8
mN6tqAM41Mb2b3MVf7Rlqh74voFb4qcV6jYMg+pF0h/m4A9DmKsUFnX4TUdXFxUNzLcy
zNoCAKixiXHrRoHk3GCOG7qfdzXV3BhfiKuRhQubSFv3WNi9yJfg7zQcdJgACqDkFhkI
QKzg==
X-Forwarded-Encrypted: i=1; AL+hErGF6pONyd9w94Cc/w8AgvPh0yZtcvI047X+JIqROjt3PA4tT2iu4UGAAIY433nkZT50O6peUsw=@vger.kernel.org
X-Gm-Message-State: APuU4Z+CifUtk4QHp2zoSGLNeVrgzwUj/kT6fhPEOIInrNMD34UqLzc7
641ltXyWyNKLw3Zus22nBXHkY47B0vgr3wur1ZOtLZDNj8NU7hk7tJ/I
X-Gm-Gg: AZFdTZdII50rxQvpRbY7SxT04g9wF2cwSQcS5svymZ/ky8O+T5xQp7F2o1Atv1UKf8l
ax3DMxlUHnUFHI9buaJBCa3zjJl9j0oyQuV/cTe29aKCFa00qGXmPgAhRGrVgqRuEfkNwf0I0GY
dpDiJ+lQOQ8ga+ftpFTZ0AM/4yZvAFnSkKWVFJ7TbWCujeKo4ahPTNXkVIpXduodx1cJvl4peMs
Dl0YDffFVQNAqIHAkHa7rUqm5nooKj8xHoJR6fsjY46soM3mCYI6r4drMC15GV5B+fgmBQ//H7/
tILrP3Nukm69U35rKBlv2e81TV8HQ2x/66grEDQWP+XVIaavma7QBnGUZUVTxEYhhJthGpTNQCL
hmBEKLHyXa/ygLH/Vz0T7hfzSXK/e9fK5xUI+BWi7yGxc4KeyopfCS8Fsm8gNGNeXtoBvOtUzD6
MmsYVzZBdv5Q8jwwiOlpfwrNETL2bk/IRT+gBQ41npA3Pv44lg3N6HA9uQcCAVtzqvhBjSFBPTw
jxHBovLkmd3IfCtSqV4Etywlb9RwjQtuHl8JWFqA/6EYZZ3okTMxq280d51daDzrEyX0K+gg//a
NoFBefONvpfkz1GloapqkGbbnCIqMZcq/dwp2Rc=
X-Received: by 2002:a05:6000:2403:b0:4ab:f0ca:853e with SMTP id ffacd0b85a97d-4abf0ca8557mr84708355f8f.10.1796308983849;
Thu, 03 Dec 2026 06:43:03 -0800 (PST)
X-Received: from grower.termidesk.ru ([185.32.132.89])
by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4cedd6e042asm5961447f8f.41.2026.12.03.06.43.02
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Thu, 03 Dec 2026 06:43:03 -0800 (PST)
X-Cc: Alexander Martyniuk <alexevgmart@gmail.com>,
lvc-project@linuxtesting.org,
"David S. Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org,
linux-kernel@vger.kernel.org,
Hyunwoo Kim <imv4bel@gmail.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Eric Dumazet <edumazet@kernel.org>
X-Mailer: git-send-email 2.43.0
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