From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.43 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796308986; b=BdEfbFeBqKQbnj0z/eONLsh+H0VHA6218NSgaO6v/aznfd+KyO9ogIAaVJY96TRMAxiB qJRBWAntuqIiDF9DL+4pVVHGL+eSIe+K0oJmYenMcnNEUEiVrAMTAUL6chRgH14kO5mxa tRni4GJTkQAuOcwRSqxN21CjYnHbv5YtgtxiBG2+u80Tf1YtOmI6DVGvDj0t099kmlUzQ NGXeZ7UBBde5PRMjhZ0sRAmUUfqtZKkOiAXC8mxuGG+3z8VVV7MtFXWMNfT7tLLoY7qUZ s3ir62AGKNWKwsaVLb8DbA1U/TX7RTQlsdvO/y8YjDjd7ubIQ1qMYF2Nqquju8sg7Mw== 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=Yczy25B8nhJUTOqyIGrwdAOIBtsSHKuxg5qWlEHw2X2uLI59MYCBmG0FCYN/VJGG7nYZ CWt7QJdOVQCExK95OwHMZX4oIYo0f4Wo2Rn9mDm2DUBog93DV3tXF7cgTg9NBXn04FlPn CMjya7pm6OgcTbwv/+2uN+w3uEeQFqXfwqjCrvHS+VaqtO+gp1mJCqHsuPqLxf9kh3wB4 WVOQ59YeNpcF3A0vaLdn/FYEGw6CTgs1prx+BMqowkR0jDfTIcCEE4aPjKSZcS6S4bB7O Um5QllBTVZGlvxZnBT07ApjkJ0XwmSEWlzVo6GBBIpDCpfkTzqFH1xRbVm7yXxcZjSg== 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.43 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 707C6606A322 for ; Thu, 3 Dec 2026 14:43:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 707C6606A322 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-f43.google.com with SMTP id ffacd0b85a97d-4cf418d85bbso622134f8f.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=tRDA90fcOM6YT6m4yBOEeJ4miq7add2rHeQI/lOThFj+8wiQaO74rmMLyhymXoWFbP fmVICnlbByMLwF1H9wlRalPTy7wkG4u1ZnuKlCvTwhO+UKlQfO1Hkjg6QrQwsZ1vPAbe mW//P+A2DVOHeM5Ii5XUDQASTG0UzjGm2pYNvD5TYyC60+y64TPsCrAiAGRumxHnZUYz d+Ppn1V3sbWYITCTwf65oOn6rCJPOqE8AeYL/oc8e7EVj7y4mLt/CDrEftv8ma4Gkfa5 JjCifMuTc9Bc7vcp5jUkCUzyGgBqs0WCfeS5k9+6iXrV4QCwNmRhESzZkbQbumd9D2xB D7ow== X-Forwarded-Encrypted: i=1; AL+hErHRdwFEPgVy8Z7qYHcbwEiU+h3BdU6NmHUXAxPmRyUAj4AMBnCBvDFeQf739MBWeUro1liM7jWbAxWJzIA=@vger.kernel.org X-Gm-Message-State: APuU4Z9avFVb00lk7zFk8/yJmp/sLEkzvduKRzpVpNH3LTLP97DDlDi2 jy3otB75zYxN45kw7iNe77GLOLsvLSlau0ipzUKd4q0DTh1BxUza+MIe X-Gm-Gg: AZFdTZcUp2I5xWNzlZ3S9xvW3wCuRqNoFfjtmsBd7fZyKHbRWyVqlAzUV+BhDqtqkWj vwfb25ePKRmCE4X46sFIHfZDK0LaDNmldnxemPUsVGGXYGNOMThHxk9vPnsR7zsxIqdVqq6HVr1 wfaQzCsFvn8bx3dGFMuUoqrxwbsjHk1Bb0+h9K2EG6uXglJCNfCkxPpfvWrl3QLHL7rOuaGd2bF Hfe5vvZ2AXQb2W8zUNLUpFYYXnFfKInOFcSu/79lg2a6GrhvHWl+52dVPhTxR51uLnQ4bIkrpG/ 4REqfTH6+qwWQlrIqq57LHFgFxzgODEbCR/IF5oc7SJCEfZfi6zvCAW6xa0f4/rBuUZ+r7HPJBr 55d30sn+WPo/9dbl5Qr8Z2JFx3W8tmhq4vz0koA9g850pq/bPykXFw7UN+ToxkrZvgFhIjD0BJM azuZCarldINnMzdmO+ERmwoNuoY66MUWt8I7yHVx9GYGxcsiCnCq/egVzYwGAL/zampoq7kXOX8 VZ77xk0vrkGyBXcMriKEGG4LLxHfg0+fyj5ra8gHa0s3j9y/TrurV8uAwELNLBc9AlXgnpgOg9O Q/7zsIYZuy5eKAVRs+8yhlO8v05borpAIMjPbV0= 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: linux-kernel@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