From nobody Sun Jun 14 02:33:37 2026 Received: from mail-qt1-f225.google.com (mail-qt1-f225.google.com [209.85.160.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB4633DEAD3 for ; Mon, 4 May 2026 14:53:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.225 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777906428; cv=none; b=GJq57I49SPKYmXyvB0GQ1Aqi6y188yo+DvUKemPo2N6apgJ+yPYbalo21Utq5qerAOGEUVfWyuHuOrZR3KWMHmgq5KUp5JEPfa31wUINc2k2oU6w6J4VhjTGMiZiOXoDPuXIU1YPYYbbJlm/QSiSMy6YjrsSKxCsU6Pm3D7D+vs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777906428; c=relaxed/simple; bh=+HKGs/2OnYxSKjzoiGas5+wk6yJPcmLe0BbCqba4bFg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QUN0cRij29N3fnwbR3xzBmcareFO2b+fDAIJM9vLsyGlCnkxORet9LQYLMXDmIuUOLCyk+ppVX9IEUGbmUlwi0/mNOyOZlu8V6WsnkEffsHR2U6+TBz9m8s6RxtRK+J5wZ6P31IHJaVXQ1HGHRvVJMJl60ZJ6mgU7zVzpYOyqwQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=Rg/p3AiB; arc=none smtp.client-ip=209.85.160.225 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Rg/p3AiB" Received: by mail-qt1-f225.google.com with SMTP id d75a77b69052e-50fcbb88c6bso2996411cf.2 for ; Mon, 04 May 2026 07:53:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777906425; x=1778511225; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SHhLI5sBgOBTw5yVBP3uB++yW6cjDecz6JHS4uWuFPI=; b=g+1497dFEsErO05YQCaADyJEeIV9jGqw6CbB/kTAvgciIyfeD8mHL1aWfFRdPWag1K 3nZ9XESsXrfcgBAIEzNe4cB6Z8SBG1ygbo3uXHdnQ8jay8UCKVlmdcWOHIgJK+3Tehck CpkaJBzzxECxla6UWCi3bga9X2Soqo9LzrlNhQXq3WG2Nek6Gc5OMMeMNILjTNWN37eZ eeuW8+7CE4YjDvyUM5AD3JVwFRCrfQT0NACESFwvEpfWmHXeYRMaf03q/H2UxDMfNXFo lkdjGc+vpWNEjJUjuAkTh++aKZDtJktyKeA9L7cwll7DKKkEQBDdBBaOI32rkFTBmt+s LVqw== X-Forwarded-Encrypted: i=1; AFNElJ8O30l/48T8dQbxI5to/RnsLhzWNV2KxmHOlu2vyll+7RHTkViwpLQhr2lew8UFjiN+qnr7EcEq4TYRsGg=@vger.kernel.org X-Gm-Message-State: AOJu0Yws5CLFjn3p0T5MyRYyYnPoVTts9f0HDi0/5fBWUMRcjRhB7dOX 4LsG8qCsjmw/RIgDMT9YZY/jtMbItr/06j3JfeglPetJyLIkuIwbVXkalYMnz8t7IOBFzd+YwOE I0b2laZpCUBQ3VzZK0/b4fxZGn/a2GS/O8CfjFYlOgwGx0+MiQfVsHeBZqIVsAD/oIR4Jr40wI8 kk6hT+zHkpa+ubrK9Due5A3nAq++nLGQ/QiJmZic6vSaYBH/icjSM660Rd1tSP3tRPYEudhAK+x hu7ro8PNVHKPbNzLvlrZ58= X-Gm-Gg: AeBDievchyrucUddMsxShhwC+0r0xViUjVY+UuX/APZCXBMRRQoZ2Jn7qDodjtmyIDp f3awbZz7usbawYcmtGBtwXEVAAnxYyAXxWuvx8vnCaiBdLEMeZT495Pbxx0+GgIFYQs7MO6tutS q6nf+I7SRpSU2HUHyy7Vfc9QrcEcfsMKxT6BgSKymfj8z1kgfUnlIHrLtVUDWKpNvZJMsf8Yssz DgIsYr8NOuAhuKlqd4F3WvkxuKF8b80UgOq9OzsYB5v8Vu9MnMjDyiuYfuXyeRq6cLAiJj19Q4z VjYbTmavfj5x9ZADJaSO+9TBniZbCrDLH4aBD3uP7EXJK9nT/Wua4Z/TVnjswtW3ib9nqE9F1tL 6uaD211xq64NuSxrWE1h3Ava0NBungujL4ynLtoRv6cwCIeXVa+OXa6q6fk64x6Aa2jHQzohpnb 9vHHLB328OJjXibVWpdC0XsjwGwMZFhuMhiQIelOJj8VrzVtTZyLFWl1nf0byoAhcRBbkG X-Received: by 2002:a05:622a:6186:b0:509:e68:22cb with SMTP id d75a77b69052e-5104bfce246mr105372241cf.5.1777906424506; Mon, 04 May 2026 07:53:44 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-21.dlp.protect.broadcom.com. [144.49.247.21]) by smtp-relay.gmail.com with ESMTPS id 6a1803df08f44-8b53ba0e66csm9616606d6.22.2026.05.04.07.53.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2026 07:53:44 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-8eab2831ba2so62883585a.3 for ; Mon, 04 May 2026 07:53:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1777906424; x=1778511224; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SHhLI5sBgOBTw5yVBP3uB++yW6cjDecz6JHS4uWuFPI=; b=Rg/p3AiBf4F0D4wlxPjxvo1QRvQUHLIhGKLb7wW/pExYm8FMLGdR/Ap5a0UndJDecG WAy+J8WIniQGRf58xAPasCupeu0YdULlBb8vhQUmIhWyAyN45X47eil6Ptldo0axNucK ykZoIcdHxbqVdHvzI+9mz+1lo10K5Z55mKwi8= X-Forwarded-Encrypted: i=1; AFNElJ/knGK25WiyyNrojU4ONLCd3Fy3bicovP9neH++QRVCxRkuVhTvBzparPREqUCus/bo4SWl6+02UyPycDw=@vger.kernel.org X-Received: by 2002:a05:620a:4154:b0:8d7:3f45:b95c with SMTP id af79cd13be357-8fd155f14camr1002870085a.2.1777906423660; Mon, 04 May 2026 07:53:43 -0700 (PDT) X-Received: by 2002:a05:620a:4154:b0:8d7:3f45:b95c with SMTP id af79cd13be357-8fd155f14camr1002864185a.2.1777906422882; Mon, 04 May 2026 07:53:42 -0700 (PDT) Received: from photon-d7fac424c0d3 ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8fc2c91fb3bsm1046315985a.41.2026.05.04.07.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 07:53:42 -0700 (PDT) From: Ankit Jain To: edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org Cc: davem@davemloft.net, pabeni@redhat.com, ncardwell@google.com, kuniyu@google.com, horms@kernel.org, shuah@kernel.org, quic_subashab@quicinc.com, quic_stranche@quicinc.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, karen.badiryan@broadcom.com, ajay.kaher@broadcom.com, alexey.makhalov@broadcom.com, vamsi-krishna.brahmajosyula@broadcom.com, yin.ding@broadcom.com, tapas.kundu@broadcom.com, Ankit Jain Subject: [PATCH net v2 1/2] tcp: protect locked SO_RCVBUF from Silly Window Syndrome Date: Mon, 4 May 2026 14:49:44 +0000 Message-ID: <20260504144945.13477-2-ankit-aj.jain@broadcom.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260504144945.13477-1-ankit-aj.jain@broadcom.com> References: <20260504144945.13477-1-ankit-aj.jain@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Content-Type: text/plain; charset="utf-8" When an application locks SO_RCVBUF, it expects strict memory bounds and disables TCP window auto-tuning. However, recent TCP memory fragmentation optimizations still apply dynamic truesize penalties to the `scaling_ratio` of these locked sockets. For workloads processing small, fragmented packets (like Java's Tomcat), this penalty drops the scaling_ratio to 1. This shrinks the dynamically calculated advertised window, leading to Silly Window Syndrome (SWS) deadlocks and 504 Gateway Timeouts. This patch fixes the issue by bypassing the truesize penalty for sockets with `SOCK_RCVBUF_LOCK` set. To ensure the kernel still defends against memory exhaustion from large aggregate payloads (e.g., GRO), the penalty is still applied if `skb->len` exceeds the advertised MSS. Fixes: a2cbb1603943 ("tcp: Update window clamping condition") Reported-by: Karen Badiryan Signed-off-by: Ankit Jain --- net/ipv4/tcp_input.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index d5c9e65d9760..569299dafa88 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -240,8 +240,14 @@ static void tcp_measure_rcv_mss(struct sock *sk, const= struct sk_buff *skb) /* Note: divides are still a bit expensive. * For the moment, only adjust scaling_ratio * when we update icsk_ack.rcv_mss. + * + * Protect locked SO_RCVBUF from Silly Window Syndrome + * due to truesize penalties on small packets. Allow + * penalty if aggregate payload (e.g., GRO) exceeds MSS. */ - if (unlikely(len !=3D icsk->icsk_ack.rcv_mss)) { + if (unlikely(len !=3D icsk->icsk_ack.rcv_mss && + (!(sk->sk_userlocks & SOCK_RCVBUF_LOCK) || + skb->len > tcp_sk(sk)->advmss))) { u64 val =3D (u64)skb->len << TCP_RMEM_TO_WIN_SCALE; u8 old_ratio =3D tcp_sk(sk)->scaling_ratio; -- 2.53.0 From nobody Sun Jun 14 02:33:37 2026 Received: from mail-pf1-f227.google.com (mail-pf1-f227.google.com [209.85.210.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 647FB3E0228 for ; Mon, 4 May 2026 14:53:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.227 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777906432; cv=none; b=LxAL6xf/RrfZG96nQfzEz//2L5hiDxEohNgzTqu4H+9xEcX+PNWM1Eo66HnYMWUKpt8UixbTvFR0dab/nehDrDQQNRmuMRGDuk9Hq/7Xe5mVDKohP4z5WtqhCHapGW8nq7EBaC73f9YASAzP6V9edigSDQkQZqaFkbAvrfEI450= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777906432; c=relaxed/simple; bh=NHQizhHkJFek9eWTi5oYmtlX7dFb8feNSqydNnqPYoo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hej1BdtzjtW0hPIprYmBIWlIn6MHUx507IjOICGrRUQB3JpMxaIUaqhFGSmBrrsNLxzzsDT70ouqbY+t68B0NkCX1c8u6UhJXsS+jVtKOmnp2ie1Obk9d+nYYW55Je6xiLIfsTd70lUEHuEvNjc7iMdH7qz/M9iTdIN8DnyQxDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=JFv78a2P; arc=none smtp.client-ip=209.85.210.227 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="JFv78a2P" Received: by mail-pf1-f227.google.com with SMTP id d2e1a72fcca58-8368a5d79d3so115958b3a.0 for ; Mon, 04 May 2026 07:53:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777906431; x=1778511231; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=NHQizhHkJFek9eWTi5oYmtlX7dFb8feNSqydNnqPYoo=; b=T3l6IXfH4uNTBxfe42QtRY/I9LFWh9mCKHkddbeGQlrZioWsEimUfeTKKWcKsrNDoQ qnZPy7wL8AOkmOTUDhFgH5gl4EACdDwsy4NE1r4Oec2vzi+Cq9ULI1kLJ1UC9Pvmk5ls VSZgI4F6w81xAzc1Z2NkV+jl8NnJLScIhafG2RmGhaFaWzWrNtbIS0sit7fR4oMpU19K hMbd0pycO3Z5/DVAPva6hjW2dVQMvjMMFy01kQB4OGP+08jP6fqwnSMCgqP0uBJjykOq lwRwpgO0wXgJB4gzSVccv8aOMlQgzY6pONNIhcXdRvjw8UskXZWCMbLlY8gv3swHpgh4 a30A== X-Forwarded-Encrypted: i=1; AFNElJ+IUoXJ6xMXSJsJhxxM38n8aarcpn0XdhximrDm/3WzrMSS+GoEiqVJD039Nqjk9Jyopjxd3ADoTEri3yI=@vger.kernel.org X-Gm-Message-State: AOJu0YyTKZeEWialiWg8wzJsPp43Q9Xj9kbF3AZ5dX69lytBt1gs0xku eiX1brdVfm4EPRfGBI2kQOxjHaE0Ssgtc6WxnhNoF1xHHqf1fXLAQOz6tZr0iK9fLnNNVCiIPIM tlxO2nNO+FYyc9IghUwRtJBPx69GmZ2pEiJeg/UYgq5FKzei/q8i/rGjVV+czfAG2FQtupyZJ2r dHGUx8zR4RlgQ8U7zzfhKAAbjCEQEmpTsaTIxcv1jaSFBBSnAW/jQSUn4oOhfHhJzIa9KiNMH5b Ia3ICEWrviX9BFNnogWilM= X-Gm-Gg: AeBDievKkqMEvjwZPr8XyCY9LoKpWQlYlxThL+uOsZUHaoCdSBWmuttPGhyrvrngmDf 90LWU1wI+sG/sa0YKTZQJ2kyjQZrNebnxkn+Jajx+SvcvUIsUCm0rhcvhjrFHgjAdZniB91MtQn Qv6pdpx3F1w480VwrXXfCMZxho0R2gikZed0QqsrYxKaAL0xxncfKimx1U/YbXKRhnNTVl4qK/Z uQ1cb671nrWcIKGoJ2NRR1ea837nik2Ytk2qvEGORHgnbXd9amnmt7Y2ITCydul7WMngVzk7usD s8VuNHL/Syo2c8Es/0V0Gu34igp7PVvykMyk6c3isP2n4aY8c4Dep9sVdYRaOOtHbsoyLw8Fbs4 t5tUjUUEntVrAEU5gW0NYkofOgIXXxFzEq4usx2y9UlPCANI6+yNSKl0ctKnN81+2dMBYhgm1hY s2w7hQYZ0Pcf93w04rPD84k4HnZsvzbPfsIfsGcJ3nFBdK1Zpu+Sf55/rGdUno0f/FSfbj X-Received: by 2002:a05:6a00:a220:b0:835:3f0b:db71 with SMTP id d2e1a72fcca58-8353f0be322mr3948422b3a.6.1777906430505; Mon, 04 May 2026 07:53:50 -0700 (PDT) Received: from smtp-us-east1-p01-i01-si01.dlp.protect.broadcom.com (address-144-49-247-21.dlp.protect.broadcom.com. [144.49.247.21]) by smtp-relay.gmail.com with ESMTPS id d2e1a72fcca58-83846887af5sm179108b3a.5.2026.05.04.07.53.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2026 07:53:50 -0700 (PDT) X-Relaying-Domain: broadcom.com X-CFilter-Loop: Reflected Received: by mail-qk1-f199.google.com with SMTP id af79cd13be357-8ee2dfd63beso45085285a.1 for ; Mon, 04 May 2026 07:53:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1777906429; x=1778511229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NHQizhHkJFek9eWTi5oYmtlX7dFb8feNSqydNnqPYoo=; b=JFv78a2PpDkIaHme3ck10Nit/5VwzBWCjaZgNBbnVbjs+P61VvgvHWjklObHY5UsXP i0nRUt78bmjxNx1Wy5lNmBPGn8oYv+YjWcVVDPl1gra+6aZA7bnhkr96igmKS9128Ukx yzBuQbAVxgj1+hMhr5/9md8y3eDeVzbaF6zgI= X-Forwarded-Encrypted: i=1; AFNElJ9/OYPIn4dh726sNhV3BYFB3ATRD9ncM5lpT33tgPM3KNgyGuqtGCYg1X1yQci83aEuwVMy+074+oL42Ek=@vger.kernel.org X-Received: by 2002:a05:620a:404d:b0:8ef:2118:aecd with SMTP id af79cd13be357-8fd127b737dmr1008302285a.0.1777906429113; Mon, 04 May 2026 07:53:49 -0700 (PDT) X-Received: by 2002:a05:620a:404d:b0:8ef:2118:aecd with SMTP id af79cd13be357-8fd127b737dmr1008297585a.0.1777906428521; Mon, 04 May 2026 07:53:48 -0700 (PDT) Received: from photon-d7fac424c0d3 ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id af79cd13be357-8fc2c91fb3bsm1046315985a.41.2026.05.04.07.53.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 07:53:48 -0700 (PDT) From: Ankit Jain To: edumazet@google.com, kuba@kernel.org, netdev@vger.kernel.org Cc: davem@davemloft.net, pabeni@redhat.com, ncardwell@google.com, kuniyu@google.com, horms@kernel.org, shuah@kernel.org, quic_subashab@quicinc.com, quic_stranche@quicinc.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, karen.badiryan@broadcom.com, ajay.kaher@broadcom.com, alexey.makhalov@broadcom.com, vamsi-krishna.brahmajosyula@broadcom.com, yin.ding@broadcom.com, tapas.kundu@broadcom.com, Ankit Jain Subject: [PATCH net v2 2/2] selftests/net: add packetdrill test for locked SO_RCVBUF SWS Date: Mon, 4 May 2026 14:49:45 +0000 Message-ID: <20260504144945.13477-3-ankit-aj.jain@broadcom.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260504144945.13477-1-ankit-aj.jain@broadcom.com> References: <20260504144945.13477-1-ankit-aj.jain@broadcom.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-DetectorID-Processed: b00c1d49-9d2e-4205-b15f-d015386d3d5e Content-Type: text/plain; charset="utf-8" Add a packetdrill test to verify that TCP does not aggressively penalize the `scaling_ratio` when an application explicitly locks the receive buffer via SO_RCVBUF. This test establishes a connection with a very small MSS, then injects small payloads. On buggy kernels, the payload-to-truesize memory penalty drops the `scaling_ratio` to 1, which shrinks the dynamically calculated window and causes Silly Window Syndrome (SWS). The test asserts that `tcpi_rcv_ssthresh` (the exposed window clamp) remains protected and stays at a healthy level. Signed-off-by: Ankit Jain --- .../net/packetdrill/tcp_locked_rcvbuf_sws.pkt | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 tools/testing/selftests/net/packetdrill/tcp_locked_rcvb= uf_sws.pkt diff --git a/tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.= pkt b/tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.pkt new file mode 100644 index 000000000000..96d3a0813548 --- /dev/null +++ b/tools/testing/selftests/net/packetdrill/tcp_locked_rcvbuf_sws.pkt @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: GPL-2.0 +// Test that TCP does not apply aggressive truesize penalties +// to the scaling_ratio when the application has explicitly locked +// the receive buffer, preventing Silly Window Syndrome. + +// 1. Create a socket and lock SO_RCVBUF to 32K +0 socket(..., SOCK_STREAM, IPPROTO_TCP) =3D 3 ++0 setsockopt(3, SOL_SOCKET, SO_RCVBUF, [32768], 4) =3D 0 ++0 bind(3, ..., ...) =3D 0 ++0 listen(3, 1) =3D 0 + +// 2. Establish connection with a TINY MSS (48 bytes) +// This forces the kernel's rcv_mss expectation to initialize at rock bott= om. ++0 < S 0:0(0) win 65535 ++0 > S. 0:0(0) ack 1 <...> ++0 < . 1:1(0) ack 1 win 65535 ++0 accept(3, ..., ...) =3D 4 + +// 3. Inject 100 bytes. +// 100 is > 48, so this forces tcp_measure_rcv_mss() to recalculate the sc= aling ratio. +// Because the payload (100B) is small compared to the sk_buff truesize, +// kernels without the fix will incorrectly drop the scaling_ratio. ++0.1 < P. 1:101(100) ack 1 win 65535 ++0 > . 1:1(0) ack 101 <...> + +// 4. Inject 110 bytes to bypass the length jitter optimization and force +// a second recalculation, driving the scaling_ratio to 1 and crushing the= clamp. ++0.1 < P. 101:211(110) ack 1 win 65535 ++0 > . 1:1(0) ack 211 <...> + +// 5. Assert the window clamp (tcpi_rcv_ssthresh) is protected from the pe= nalty. ++0.1 %{ +assert tcpi_rcv_ssthresh > 15000, f"BUG DETECTED: scaling_ratio crushed! r= cv_ssthresh=3D{tcpi_rcv_ssthresh}" +}% -- 2.53.0