From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796308985; b=JNI+Jng5tFCvSLT8NJOdDluQiMqydoLmc235g11zmXP8dhLmur2uw7xtCjuJOqxIk1Ao NyMZV7zf8Y+v1U9uanvFaFf9GsnQt4VAGAI/eq3KSmCAsyyWTT7/p8rvad98RVrMX9Fx/ /m0NarLemyGel6EDFwzqwj3CqxGuGiIvBZwcRJ/dlacEaHRj+lSgEkjW63kL9rqByQYpz 7XhLHRYmFXeLB6bc3VRk3TM7pShFugH78zEwd1EOm9SBIdLBjsFCJMlnYd6868opaA0Vk jNI3Xww4uMCwwhoq1RNkqkrwYGCWTDvwo+DBBA7BBiVGomqZplg4daV2bEKbNLjNl0w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796308985; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: 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=gKhTiHEeQPzxOZCXCjyAkdRnEv+bp8QO6i/2kOL06T+BF9Rwy8GQfQocp7+u4kFmvq4x MTEWItZ8g4xGfJnrSPhqu5NK2d5jkJOPmKJrTCW2AMrMxWSTljd9iD3/XCVJUQozCIYAy vLETxqaqFO80HxORQKLQ0fteWiMica7yAXb7/t0T4u5cipxG/sVUEkOxarnSjLUxNhCP3 2x1kYAUVtn+NnZEUZlticMco4PVkrotxvuWMFz+PMQVdy6ENmtEbtHf5mDFah16jGdsws XzJ9oMDLJCerOox3/hvoxDE+f/1w4SYdwAlweFMIHUCbxwT5CZUAs6BkhDccoVEs6NQ== 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.44 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (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 70C5C606A32C for ; Thu, 3 Dec 2026 14:43:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 70C5C606A32C 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-f44.google.com with SMTP id ffacd0b85a97d-4cf418d85bbso622136f8f.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=gbolvlklJxLb+mONxy7wdNnxn3vYdkK76vY9mH3iYdSmdvIVxTyq+bgMjpZgdgb5T6 AJNPdrISO80JwCpGEeHoAoeqEBg0bLW0FuKQLlckHBqOaSnaSCv+hEpX98y5p5cqoaGR yy5xvVEto0UDXBc/XqA1h2L0/4/X20or1VPi6Lsyb/SPUyTUNp8VCseatBflJpW6j6NY axZQfnc9cWgVcy8CGSvsWQVrKXha9rExTOedvazcV8iM3s9qm4OxWxIvmjp6LtuhaURE Ok8wKFUS084LhqMyEI5kL/T9dfh6BBCmM/+7vdR41Fk658zhyskrwvvBl3VCIU1umJgA 3b6w== X-Gm-Message-State: APuU4Z9PwRFwzbTJhLYud1OL4UdxI8oX+PrZIxI5HnItyoV7hBzKMSzG U+HsP+qANyvjqeuTKfZ+D6FzXHvcjdv/5bEimYblyG6yTDh3fJyw+vXZqYfo7U+P X-Gm-Gg: AZFdTZeclPRmtHU0B/FAv99V9skCB5yCk7HtvgRtC40qnDGk9Z7p7mMvVH+GEJRG5Ez u1vzn/bzKSxgIjvT3a1VLbgek0GAZE/508nHwBs2EC0QMZx5IIs/MjTE3yMDBxcJarVRdncB8Oz DAIvTXvxPb76+c+O6aL4rNVZgdjd601HlzYh95l8CypiyaSlwdSoCgoEtXCNGQtNPQ7b8pfxZUR LwlXC4xpdI65ThLLS2K31+fPSFjipiJVYGHqPUSvbEXLx/w8qM/o3pwvpJ4rUXO0aN4uc2sHWpp 3WFcd7jtG+5lkeICi1Uu/G+SPvmxuuj9FXRzF6c0RKrLBRvmJe/K5vgHcZJS/ShRnyagry+WSCV epbCdCu+UAfQ13oKHEDyF7QLNI3cJAx2DIkB7YAlpN8PEtBLOSYHMc9YpDBxQNdL4miKFinemS2 Mxx2OrjBOZK7iEVfZHiExA0TLXPojmtqQ2Fn9rUhnNKXH326ri0pOAXl6PSHohy8QxJKSeR8vuG Zc4zXc9WEbA4vaHcVuv/gXS4MWyQSTC0GB7FHPO4sqlQdKbaUln5auEXp5jF6vk3beZHYc94o3a rWmSd0VbxbYaXttcG9CrCIFspL3FgJTCdYxHQqU= 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: stable@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