From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.45 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== 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== 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 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 ; Thu, 3 Dec 2026 14:43:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 78A85606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com 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 Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4cf418d85bbso622135f8f.2 for ; Thu, 03 Dec 2026 06:43:05 -0800 (PST) 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) 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) From: Alexander Martyniuk To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexander Martyniuk , lvc-project@linuxtesting.org, "David S. Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Hyunwoo Kim , Kuniyuki Iwashima , Eric Dumazet Subject: [PATCH 6.1] tcp: fix NULL pointer dereference when restarting a Fast Open listener Date: Thu, 3 Dec 2026 17:42:52 +0300 Message-ID: <20261203144253.831815-1-alexevgmart@gmail.com> X-Mailer: git-send-email 2.43.0 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Hyunwoo Kim 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: ... 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 ... 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 Reviewed-by: Kuniyuki Iwashima Reviewed-by: Eric Dumazet Link: https://patch.msgid.link/avMkfJrXhCFXn8M_@v4bel Signed-off-by: Jakub Kicinski Signed-off-by: Alexander Martyniuk --- 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