Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793216994; b=HB7xLV84+30W9w7d0PrgBybBSd9UxD5lH5ZuKNDP9mzKP9SLWLpB/jwl+Enu3bxcUgOL OnW1IPyI+iSsNbPc1ilVjaJBw6inNvw2qiwW9bsJzM0gXW52Q3khwSh3goTnJlIizt3hK xT2Gcnn5v/GacsarqIBsaznueO+KHcnFCdxK4SY2a0vpTpntjQKgsX1jC8s2th8rJYWUD Sv4WF/n6gRqZJ6y7Lf+d45NV7yZKbqbozESulswKm0XS7btd92MdW+ZpL2TtzOXjhepJT McfaWP4YxrIl/rgIunJA501bEDufWtM7mh8fuxr0EFQ28HZdj/NGq/RtarCUqhKxU+A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793216994; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=qpRMvgO9GoOlEL+Rqvl/cbgdroazmARHuQY33LAAr70=; b=fYGLqHQTswl719+9SD0v5f5YZrEWQuHoUoMyiXCu0OU9HSGKc4AdV9ZYgo+UMUVqM2eX hLHK43FTwz7lBBtEpImDB2u5oIi1HlENbYRFgx3NXoaAEqjw3XQ1MM2CokM8uvF2WsO1U SPwp08mK/mviz377olMzIjRKhxJmQmVuvU50mvNHewTvvmakqmPLp0yDphNJWYA0RvqmM dCxebQ3r1YMPKIIOMsXfIK2jwMigVNcWq38mXwF9Jirhfkawhp495ZdMS78sLd+h8oM8S uMOIivzfVk2ks44eMwM0X0QKnZFQivb4pXnmcH9yS8ggo3UMEF7hS13ZdWHHthfHVog== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sM6opmQy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 814D7606A326; Wed, 28 Oct 2026 19:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=sM6opmQy Received: by smtp.kernel.org (Postfix) with ESMTPSA id D529E1F01825; Wed, 28 Oct 2026 19:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793216994; bh=qpRMvgO9GoOlEL+Rqvl/cbgdroazmARHuQY33LAAr70=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=sM6opmQyliafXqv7tTRkVFLe2ouLxwBEfShgKnBIrxvaR2SLDHVEyMru09I8cF2b7 Nv6LGLg6XNrBCWHJMACwOXDosLYHL58w3AQw6ZnRX6vBycwOX57Dvvoz5aDbhJVeuh AbsqxfTky6FSyswLIM1sVanP0fNFRVLED39mVxXo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , AutonomousCodeSecurity@microsoft.com, "Cen Zhang (Microsoft Security FORGE Labs)" , Jiayuan Chen , "Matthieu Baerts (NGI0)" , Jakub Kicinski Subject: [PATCH 6.1 1752/1887] tcp: fix use-after-free in do_tcp_getsockopt(TCP_CC_INFO) Date: Wed, 28 Oct 2026 18:04:08 +0100 Message-ID: <20261028170539.327709907@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261028170459.200466217@linuxfoundation.org> References: <20261028170459.200466217@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cen Zhang (Microsoft Security FORGE Labs) commit 385e474086c2e7e29e2dded690be40dc273e20ee upstream. do_tcp_getsockopt() reads icsk->icsk_ca_ops and dereferences the get_info function pointer without rcu_read_lock(). With BPF struct_ops congestion control, ca_ops can point to dynamically allocated memory that is freed concurrently, resulting in a use-after-free when the kernel dereferences or calls through the stale pointer. BUG: KASAN: slab-use-after-free in do_tcp_getsockopt+0x2037/0x23e0 Read of size 8 at addr ffff888013701258 by task exploit/149 do_tcp_getsockopt+0x2037/0x23e0 (net/ipv4/tcp.c:4564) tcp_getsockopt+0x91/0xf0 __sys_getsockopt+0xf7/0x170 Fix this by wrapping the ca_ops load and get_info call within rcu_read_lock()/rcu_read_unlock(), and using READ_ONCE() to load the icsk_ca_ops pointer. Fixes: 0baf26b0fcd7 ("bpf: tcp: Support tcp_congestion_ops in bpf") Suggested-by: Eric Dumazet Cc: AutonomousCodeSecurity@microsoft.com Cc: stable@vger.kernel.org Reviewed-by: Eric Dumazet Signed-off-by: Cen Zhang (Microsoft Security FORGE Labs) Reviewed-by: Jiayuan Chen Reviewed-by: Matthieu Baerts (NGI0) Link: https://patch.msgid.link/65fd3816ed5d541d9edd4bf4fcf97104a2cf907a.1787870710.git.blbllhy@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/ipv4/tcp.c | 4 +++- net/ipv4/tcp_dctcp.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4209,9 +4209,11 @@ int do_tcp_getsockopt(struct sock *sk, i if (copy_from_sockptr(&len, optlen, sizeof(int))) return -EFAULT; - ca_ops = icsk->icsk_ca_ops; + rcu_read_lock(); + ca_ops = READ_ONCE(icsk->icsk_ca_ops); if (ca_ops && ca_ops->get_info) sz = ca_ops->get_info(sk, ~0U, &attr, &info); + rcu_read_unlock(); len = min_t(unsigned int, len, sz); if (copy_to_sockptr(optlen, &len, sizeof(int))) --- a/net/ipv4/tcp_dctcp.c +++ b/net/ipv4/tcp_dctcp.c @@ -203,7 +203,7 @@ static size_t dctcp_get_info(struct sock if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) || ext & (1 << (INET_DIAG_VEGASINFO - 1))) { memset(&info->dctcp, 0, sizeof(info->dctcp)); - if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) { + if (READ_ONCE(inet_csk(sk)->icsk_ca_ops) != &dctcp_reno) { info->dctcp.dctcp_enabled = 1; info->dctcp.dctcp_ce_state = (u16) ca->ce_state; info->dctcp.dctcp_alpha = ca->dctcp_alpha;