From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.216.44 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796454846; b=BfoJ4otoXtSdbqbS3qv8pDVMXApiAa37jzm2WB4eNFmfYRZthTat2Y8VDIh2JhSGAOqu /LBTq68yXMzPHjLzwrh0XMgTA6cpsIQxDfeGbUYqJ47Ele95bARcyNd/EeR+4gpXGhwQt UmsAzRx5MPOvvOiGqbdvwxyDpm5KfSLoGw6X0h32iCfrUVw4rs20TcU0sEaqCwi4DXqbp 6O0oYcBwyw0kZAFVwARCFbuZ4m1SXQvSjscbG4cf+p+aJ4z5KI8hOc0nRr/oGGfs+sbrH L+a4NCUFdTwk12KNHQZpTgmz8c0YY15NGEX+vaYJT061aBLL+oyiuiGV64LmKMdC6wA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796454846; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Content-Type:Date:Message-Id:Cc:Subject:From:To:In-Reply-To: References:Content-Transfer-Encoding:MIME-Version; bh=nuAwiXOEsZaoyZP9NG8J5YNoUozuGUp4gcwbDx980U0=; b=LhPRsYDIH8gaXR1cB8em9Oa2rZYRl+Xe1fCaOuZin+bprZoZHNkXaqeX536+vLYafFF8 qaEkQmg80kqosbwdJqovvHdkqG+e/9sjZjLFgWcY1GANY1iUSGkv8c7Qt0eW2AXJ746An Dv9sPifOyzyUESOjoKaEikcHtUQ5Nnv57iA370lZeN7X/xkDODama+P2e0lMg8wPLRlZX qoacgtKHEa2hiwPYLStN7zx2+B+/1VkX6I1nzNDUObJVm1ZSvCL5ovy3vngpZgTOSyYcg B8x4vyRVWt/GoHaEWeBjlWWkGBS44FVUcpUtK1vSfsWPBGxRORQyP+TW/pt5tBCeTxw== 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=DQ0uLNVB; arc=none smtp.remote-ip=209.85.216.44 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.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 6131F606A322 for ; Sat, 5 Dec 2026 07:14:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6131F606A322 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=DQ0uLNVB Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-3b405d8f1cfso987537a91.3 for ; Fri, 04 Dec 2026 23:14:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796454845; x=1797059645; darn=vger.kernel.org; h=mime-version:content-transfer-encoding:references:in-reply-to:to :from:subject:cc:message-id:date:content-type:from:to:cc:subject :date:message-id:reply-to:content-type; bh=nuAwiXOEsZaoyZP9NG8J5YNoUozuGUp4gcwbDx980U0=; b=DQ0uLNVBibAjJWIx+qvY/vsRpLRGa3eOmgwfetfe6KOn9v6CWxiVzFCkSvg5TZWxx8 FT8jEBtaPsREDKV7aXRaqCOJwRtwpLq7uUeae5koJMl5zbcCqPtgDrKe7TSoMi2clYFW l0rg3k1p99tk0fTlBadTKGF5qlbsxyIgt9dvsueC+gcKkHDLiFSTu5FxoUQglXooL0Ix mEEqV50Lmoh9bm2JQsAtXU5J3yLeicfDa5CUez79y8s9KQmLr04zm9011lSRLO7u9uDQ K9p/cOeX9ot/kxNkYUM26xPqivo4iiw8+GpyFOSLElrsoK9hvvTcKwwbwTHhykJouWkF WybQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796454845; x=1797059645; h=mime-version:content-transfer-encoding:references:in-reply-to:to :from:subject:cc:message-id:date:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=nuAwiXOEsZaoyZP9NG8J5YNoUozuGUp4gcwbDx980U0=; b=1EYnR/quPVx/1Navfv5h+RC2ZsC0XQI7XuefxtdW9AB2U4B4IdjZzZYdV+R13Mu5AV tVVCO5fcGo61IaQZNL6PH6usCZOakQFAccaRRNBGQex5yYY/D/WxFaZJ3e2cdZNew2DP W90fprnPaIw71LVb7b0WX7U9BBgkU9QJhcjz6mOhKfffCXAgKFwPbaRk3C04LP98mHn3 MNZABTZ+MxwgiLOyYzXaX4j+DhggAfyrGc53gg3UiBC7EbGuH48cAvwiTJ1hCE+8qZxp DAzhO4h95wJ14ii3XsrmYYPrJPpqLUzcnhHbBVBp/Y72Tc2ucmUvvc3duW2uzLza+gyc FluQ== X-Forwarded-Encrypted: i=1; AL+hErHfTa3r78RyQ8moYb/w2fVf5OzTRPlNJseC8mMEtkVa9KEJjxhNOcKTPphXg6yeiDbdTIHctMk=@vger.kernel.org X-Gm-Message-State: AB4q+uFHXd9WElqvPneaZ0/zMXpCIrreb8A/Z2K1IoHsa5inrO/+g6Ub 5kCu6NzpJU3WhY0C2mTUzEVdtNmK3B7/N285HUColtG4Huc1yHcV8NBT X-Gm-Gg: AZFdTZd9J9q6jorMpySFNEmWn0yumB+Wjq5zj6ANWBLidMI7XgzM1JW4okCcYnWPHrD sp0xjPlna52/oqt/mkaFk1bUkDqPMxYstxydjLcC7ZxErdxHanfZgg7oHpaPdUS8d1jDPnim+eH OMzhKCfYxJdsdFMhYmWb8bYsyMW1K7VJhMcBPw79X5kU1PL7UXHs5nkTgQC/fnN0Bkrb4l7jFyl MC1DXm2qt1dqYx/XPNroiFm4KxuhnhKDw1FFGmrtzTyVpghkUyIE4Gulcw8Ot9vG1i3n+X8QbD7 500IB5ZuQK9l4naumRqhv/e/I4u+JMckVYa73vhrXG166l4vALv88+DFlpVcfqHiW56Rj4YXYgD DflHREL4oj5n9KsdfxSUk485GmxRQhtchrjx3e10nLana/VqYL27q0smcBCVTCyrsJcUTPx87LQ Hj39Cpa19/i0b9kqi8UVK176lsZPdk6LAZYL0Gj97dXR8dSnJNzBHGyF3Grea5oC1r8lZJmrUfT ZvSyKginB0UUtwIeqpOmJUqTOZVoL4aBEJywOFyevWgOr5K7QmQcX0ho1t1TSrUWchAEts0qn1V ie0fIbCS2FI8DtfblKYAVirVn+Icis3Kv2Fec7l4b6a2iqFo63yadsezl1iaGzEb5QWhBPPU94c 1gxncaICGS6q0uo95i4xNwLnJrESZiF/c4UBpiJwf2bW6y88NX64UNEg= X-Received: by 2002:a17:90b:17cd:b0:3b3:cf61:dc65 with SMTP id 98e67ed59e1d1-3b5e0692b19mr4063613a91.23.1796454844103; Fri, 04 Dec 2026 23:14:04 -0800 (PST) Received: from localhost ([153.61.198.248]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8de1348e8a5sm2921796b3a.47.2026.12.04.23.14.03 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 04 Dec 2026 23:14:03 -0800 (PST) Content-Type: text/plain; charset=UTF-8 Date: Sat, 05 Dec 2026 07:14:03 +0000 Message-Id: Cc: , , , , , , , Subject: Re: [PATCH bpf v2 0/3] tcp, bpf: fix CA state on open and the TCP_CONGESTION name check From: "Alexei Starovoitov" To: "Paul Moses" In-Reply-To: <2otRMj-pH-vkYkLYIT6dpXg8UAuU1t2qabqsrXWCNC70Ql4DRMtxzPZXfKbcNvHXSHRuP-oRVyQqflfD9K_55OnWL1ORrbQAdQYyBNqYo1c=@1g4.org> References: <0qI4bliEJoe1Gzuxoccq94xz28S015yDsjw2nfkjEAyABbd6OQ3d8MEGJ5WX6zuDQhbfOH2IxT36YERbqvYrlYwHeaRGXNsWeurXQahMGH0=@1g4.org> <2otRMj-pH-vkYkLYIT6dpXg8UAuU1t2qabqsrXWCNC70Ql4DRMtxzPZXfKbcNvHXSHRuP-oRVyQqflfD9K_55OnWL1ORrbQAdQYyBNqYo1c=@1g4.org> Content-Transfer-Encoding: 8bit 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 On Fri, Dec 04, 2026 at 08:50 PM Paul Moses wrote: > 1. The LSM hook selects nv and runs tcpnv_init() with bpf_chg_cc_inprogress > set. The nested CA change returns -EBUSY. > 2. Patch 2 clears icsk_ca_initialized in tcp_ca_openreq_child(). > 3. tcp_init_transfer() calls tcpnv_init() again, this time without the guard > set. > 4. The nested CA change succeeds, but tcpnv_init() continues writing to > icsk_ca_priv after the CA has been replaced, corrupting the new CA's state. The steps are correct, but step 4 is the bug. It doesn't need steps 1-3. bpf_chg_cc_inprogress is set only when bpf_setsockopt() selects nv. Every other way to select nv runs tcpnv_init() without it. Remove the lsm prog and keep the sockops prog: setsockopt(lfd, TCP_CONGESTION, "nv") before listen() tcp_init_transfer() of the child bpf_chg_cc_inprogress == 0 tcpnv_init() BPF_SOCK_OPS_BASE_RTT prog bpf_setsockopt("highspeed") hstcp_init(): ca->ai = 0 ca->nv_min_rtt_reset_jiffies = jiffies + 2 * HZ <- ca->ai hstcp_cong_avoid() hstcp_aimd_vals[ca->ai] <- oops Both fields are at offset 0 of icsk_ca_priv. > This does not happen on unpatched or with [2] applied. This sequence is the same on all three kernels. It's the issue from [3]: ->init() writes icsk_ca_priv after bpf_setsockopt() returns. Here ->init() is tcpnv_init(). It needs its own fix. bpf_sock_ops_setsockopt() can refuse TCP_CONGESTION in BPF_SOCK_OPS_BASE_RTT, like it refuses TCP_NODELAY in BPF_SOCK_OPS_HDR_OPT_LEN_CB. > What about oot modules? bpf is incredibly intricate and I'd imagine is forced > to be less considerate, but it's less the case for net. Out of tree modules are not a concern. That's the same in net. sol_tcp_sockopt_congestion() refuses "cdg" by name. An oot cc with a pointer in icsk_ca_priv is not on that list. A bpf cc can switch to it and overwrite the pointer today. > More historical context: > https://github.com/torvalds/linux/commit/8919a9b31eb4fb4c0a93e5fb350a626924302aa6 > https://github.com/torvalds/linux/commit/be5d1b61a2ad28c7e57fe8bfa277373e8ecffcdc be5d1b61a2ad fixed a leak in cdg. User space sets cdg in TCP_SYN_SENT. The 2nd tcp_cdg_init() loses ca->gradients. Only the lsm prog runs between the clone and tcp_ca_openreq_child(). It can't set cdg. Nothing changes for patch 2.