From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.210.173 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796454845; b=khUptUhr+S5nTuJOYJCOTxHsFLcA3J2DQNAIbHo/TX9uaWYbbLBoOyJtho6YgyOMIx9l 7fa7uTDTqMe1lbECU3wyCzPYnpTftXIYGqhJHjvRVggt5FwkkQHILp1NlMkKX7sQPWMg5 Uqn7jVO5gIp5Rr/WXxmu9wkRnkxyqAqAJyRJ60fp/N4cL6uyCTVWLm6ON1YGaPMn06CnX TyQGFQ/9mTZZxwDACHbi1693tZF80j4KHUHY2pm4lvS8pUYuxnKbY89Yf0raw/VJ/LaUQ HskzEx7WLxmVrZfD4ofGuLsbJM3SSEmCq0LKWdA6ta9BAOqAlqMj+zCvOqWaSXe9kBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796454845; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: 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=Kiy1475IPKurYrFQ7Y5tl6zEIBjS7j+/eJ1dhMDQzr2bu8VvFijfnssAsb2GbzLyMina ++EVyYAirU7Iw7VqZEZLAorqxgPJGX/oJd7oXdxvQ47EQ314J6ybTV4m3/iS7kBNumDWw bZ7Jsan/6PHmtrBNcRi6IHOY4/kM3M7P9LPWrIo5+RI76Yh1jYQ9q9CbOPR4ZtIwZ99cB /9ZmspcdXzXoArKod3sQdzAjghjxy1jZR10y3cRr6w4e702nFQXs65qYlWCgXkmSn67T8 d8finUzKbBqL8rSPJHLsm/AhJ6WkMPxyuxO5Ma0WnzW17rMAIEbfAKHvpii6mdqJ3sg== 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.210.173 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 638A6606A32F for ; Sat, 5 Dec 2026 07:14:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 638A6606A32F 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-pf1-f173.google.com with SMTP id d2e1a72fcca58-8dff56e9033so60361b3a.0 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=z5CppQL/tEQEd9RppDGiCeS+6mXwEQ3z95HBhT9kTfZcZGW2/SujnsuoXAryR2gYi+ mHUQVWbQbVop9+Xc/k8RwKsw5MgGGoxRgFmmorLZSCMKEXaxwYDHCMqu3LwwYFe0jzFX HQNaOfO2HTgbjNUn7KoKsKFNNTOtMq0NMDPoFM7aXFhKQfm6bB5DoXCXtEI6aSXeIQhj WZW44oI1SK0wQx/tIDUTI+Cf9DhXd8DSDamKpV2Fytqn5vZ67DQT4ryGB8N5WH6cuDJZ LDOCx9LcUyQTmw9E2ejbEqoXBir5aWklKMHlCgSHk2jLZEaRSB6itMaEXSy02N62vtK/ 9a3A== X-Gm-Message-State: AB4q+uHoYCiDT+j7OhlCkAsF8z8iKllfvZwt233Rg0nGH0ZPGqtq+rp0 kWjnK2kGyexpiu+THQqE8LrssDKjdWEHMaBo8bo4T+nSnQIRBEu153l3 X-Gm-Gg: AZFdTZcJrkmh/BXKBJfEZH70y0TMUaRiXFndIpA4CyloAksbrfk75gede41SW/le3ek XPN5QmFETpPBAks34iaZIr7vZPn0qxVsUC1zpu4cV/dNVjI+HvwAhTMTGSuq5XVRAU4Op+q8GkH lUTWK1h65ulvHkiFX3wthc5WzyrxhpSTTotT8P+4GGORevvzDa9pqsW/cOIv7W7zaPMRognatYG aTTa4lvLQw6j5JGeK5Q8PpPqpCzgp3kAcR4bbwWi2q+pgC/BNzhMutfDdVXKFLSFAYUiHxbHYxI R8g3fwpZckMB4UpqCSC9SMcPk0W9M6jcnza4/644gehJA36b5q1raM/xvWvYadDXgeotaO9QBkG Hh18mxrWsG0EnNfwK3sPGwVTAq7SYCyWY3a3jZtgZ6IoFv4obn4x7+0Qfvs3faT0yYSrKoZsLsH 6R53wyQHH4PskSnh7yPu6QSnKItT4+7ySakfNnDMu5+fNrPRplTw9R2KVyIYCz0Nvi9Yn+JIVTq OeQsWebFNh6k6iU51WQMPkWgVUjcJ/ocI4COQ0MRywp8WxleL53L57js/+MYQPyh74yyarF/+9w EE4N7feeBZ1ScRrBALL0+zjD6ORrvCZWtyXdEnqdZPFPXYyOdmCdFOfJiOUb1I6KWUWZBCNozgf PqeTLrnTQ+cd74LKmfYJpKpHnI7RXScEZdxbrVGCDrHTn4itcCX8CHUw= 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: bpf@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.