Article View: linux.kernel.netdev
Article #6851Re: [PATCH net v2] tcp: limit tcp_tso_rtt_log to a valid shift count
From: Jiayuan Chen
Date: Fri, 23 Oct 2026 14:50
Date: Fri, 23 Oct 2026 14:50
88 lines
11686 bytes
11686 bytes
On 10/23/26 10:40 PM, Yingjie Wang wrote:
> tcp_tso_autosize() right-shifts the u32 returned by tcp_min_rtt() by
> sysctl_tcp_tso_rtt_log. The sysctl uses proc_dou8vec_minmax() without
> an upper bound, so it accepts values through 255. Values above 31 make
> the shift undefined.
>
> A process with CAP_NET_ADMIN in the target network namespace can set the
> per-netns sysctl. With CONFIG_UBSAN_SHIFT=y, setting it to 32 and sending
> TCP data over loopback triggers:
>
> UBSAN: shift-out-of-bounds in net/ipv4/tcp_output.c:2264:30
> shift exponent 32 is too large for 32-bit type 'unsigned int'
> Call Trace:
> __ubsan_handle_shift_out_of_bounds
> tcp_tso_segs
> tcp_write_xmit
> __tcp_push_pending_frames
> tcp_push
> tcp_sendmsg_locked
>
> Limit the sysctl to 31, the largest valid shift count for a u32, and
> document the accepted range. Writes of larger values now fail with
> -EINVAL.
>
> On a UBSAN/KASAN build of the net tree, values 0 and 31 remained
> accepted, values 32 and 255 returned -EINVAL, and TCP traffic with the
> valid boundary values produced no sanitizer diagnostics.
>
> Fixes: 65466904b015 ("tcp: adjust TSO packet sizes based on min_rtt")
> Cc: stable@vger.kernel.org
> Signed-off-by: Yingjie Wang <1075151112@qq.com>
Reviewed-by: Jiayuan Chen <jiayuan.chen@linux.dev>
Thanks !
> ---
> v2:
> - Attach the upper bound to tcp_tso_rtt_log instead of ip_dynaddr, as
> pointed out by Jiayuan Chen and Neal Cardwell.
> - Re-run checkpatch and boundary tests on the corrected patch.
> - Do not carry Eric Dumazet's Reviewed-by tag because the code changed.
>
> v1: https://lore.kernel.org/netdev/tencent_53CDCF8AA0022B75CF72A294CB9993D2FF07@qq.com/
>
> Documentation/networking/ip-sysctl.rst | 2 ++
> net/ipv4/sysctl_net_ipv4.c | 2 ++
> 2 files changed, 4 insertions(+)
>
> diff --git a/Documentation/networking/ip-sysctl.rst b/Documentation/networking/ip-sysctl.rst
> index 8edd2eb2a..66a54c510 100644
> --- a/Documentation/networking/ip-sysctl.rst
> +++ b/Documentation/networking/ip-sysctl.rst
> @@ -1128,6 +1128,8 @@ tcp_tso_rtt_log - INTEGER
>
> If you want to use the old autosizing, set this sysctl to 0.
>
> + Possible values are [0, 31], inclusive.
> +
> Default: 9 (2^9 = 512 usec)
>
> tcp_pacing_ss_ratio - INTEGER
> diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
> index e3760daa3..bf193e7ec 100644
> --- a/net/ipv4/sysctl_net_ipv4.c
> +++ b/net/ipv4/sysctl_net_ipv4.c
> @@ -26,6 +26,7 @@ static int ip_local_port_range_max[] = { 65535, 65535 };
> static int tcp_adv_win_scale_min = -31;
> static int tcp_adv_win_scale_max = 31;
> static int tcp_app_win_max = 31;
> +static int tcp_tso_rtt_log_max = 31;
> static int tcp_min_snd_mss_min = TCP_MIN_SND_MSS;
> static int tcp_min_snd_mss_max = 65535;
> static int tcp_rto_max_max = TCP_RTO_MAX_SEC * MSEC_PER_SEC;
> @@ -1406,6 +1407,7 @@ static const struct ctl_table ipv4_net_table[] = {
> .maxlen = sizeof(u8),
> .mode = 0644,
> .proc_handler = proc_dou8vec_minmax,
> + .extra2 = &tcp_tso_rtt_log_max,
> },
> {
> .procname = "tcp_min_rtt_wlen",
>
> base-commit: f4377bf85887f57b59abb5479f7660a81ffe4449
Technical Details
Message-ID:
<af2ec5b0-7c62-4c6e-a28d-33ed401020af@linux.dev>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351118-linux-kernel-netdev=dewy.ruReferences:
<tencent_31D2FFCCE76C50A695A1270151F825E90906@qq.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-351118-linux-kernel-netdev=dewy.ru From: jiayuan.chen@linux.dev (Jiayuan Chen) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net v2] tcp: limit tcp_tso_rtt_log to a valid shift count Date: Fri, 23 Oct 2026 22:50:28 +0800 Organization: Usenet Network Message-ID: <af2ec5b0-7c62-4c6e-a28d-33ed401020af@linux.dev> References: <tencent_31D2FFCCE76C50A695A1270151F825E90906@qq.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: usenet.network; logging-data="527716"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:VAipE+imYN8AqVta+HOZ1KJTpiU= sha256:t5CqM44CFLE76qCvIo4hccmgE/g9pXwMIKM2Cl71b+0= sha1:p/gn+RjAyi1EIy5+EeviuImnCy0= sha256:Yne3CKo9W8/UHKDmDImv2FEXFdV2cMW6K3b/NKakVo8= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 6EC351114EA; Fri, 23 Oct 2026 17:51:14 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -2.05 X-Spam-Status: No, score=-2.05 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, HK_RANDOM_FROM=0.999, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (1024-bit key) header.d=linux.dev X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id VwmFTGoiDmUD; Fri, 23 Oct 2026 17:51:10 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-351118-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=linux.dev X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id D5C081114E9; Fri, 23 Oct 2026 17:50:59 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id 93E162666A; Fri, 23 Oct 2026 14:50:53 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1792767052; b=mPSKGegv0eWm5XkfDxZ+Za9BQv3lLKBxRtLnh8oQbcFYUPS1x32/QZuB7Lq/9AZH4mIG FV4Zmwzh6hISdeeC4ZoTSbsfy5RhFaKiV2DVGAEVgwEh9j9Yqk0jHrSRRht9YXWCvxIP0 3d6pfbWFMMG8eQpufpGKl2Cig8mTInQTtY3+QtI28ZKGpu6YBdvnyuxP+XxYaCOW5YNiv JG1+16uTTcNzHx0Aiwpp9ezJ96hk4eUoAW96J4jTazJpWezNkDdMNpbVuVn+r4XXCBQ8n e9/ceFh/kghAhzeFx9fPhmoMGplf4W5il6qx5/ZZX9OhGdq0ODtjx+WgFy8h2SS6zEA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792767052; h=X-Original-To:Received:DMARC-Filter:X-Envelope-To:DKIM-Signature: X-Envelope-To:Received:X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date: X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe: List-Unsubscribe:List-Owner:Precedence:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=cx7sW0XE3e3GkkuXCIa8aE7dwlRl3GBZAuCQy670DI4=; b=p+FDyLJ6Jl5YmwmFK5Hog3xVbL85TVp2iBw1p6AUz9B9YalGrNEbeRQIA0mFuUALJCP2 S7eM1+yETHFjOCzTD6nHbPzI/mB5KGUJk9AZO0oo0bBFjKWrVP9Mp0dLlor9JIGkI/Xws WGwt32e1WC+LmtVQbiTaTc3GC9X2FA+C+em/T2kzfymJdiI3iaVAVkj8P64dUudEe09aS /ds9+BD86ziyuMdsOnKUYjeX7XaDNN/T6QBTZ+eXcgX/Tozt7aAEss3J2wmT3dmW7X9Yr h0wJQy2sg0jm+4no43GcKHp9YYTH8qv+p+7qL6t8qGuJcDa2YoiuA4URbrZXu/r37Jw== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=clvz8avz; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD4B7606A320; Fri, 23 Oct 2026 14:50:52 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=clvz8avz X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.80 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1792767046; b=vtz45F2bM226ril4kKWBuzmK304SrqySkOcGpVQfns4L/rVQH79IYonJsAtIl+6eAemK Cir9gC5I841uomwlU9QN9HJ86NPq9o8F8YOQaW8IjlwWwwYgHUPKAACznIVdbXmveF4E4 /Mf5/teTwWXcUD7Pp7yqJG+flHA8xmvMT5NTlpZtSTliDakEJeBX173S24MAJvgX3QSBV qdh8ndytUFXp9YKtNzfUktZiE/ZhrQD1zBv72UOBRIXDlnthZxpsfWYBf5kEk52OmhM/7 JwgOTch2nSVxQxYDZ6SP58i8lUrcqI08wtxTWTwMkcAHB1Sd9Js5tGOotWGPClKY4uQ== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1792767046; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Subject:To:Cc:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=cx7sW0XE3e3GkkuXCIa8aE7dwlRl3GBZAuCQy670DI4=; b=kYzlNJNzUHGb6dk1vm9hVbOkxWhpnkuzmoaSK4+ntUMD0FL2lyV+3wEc62cQcsb+eFEg dFZDgblEI4WZoHZaC+MMPbLAtWqbzvQL2p/NIZxI3felCX11heqT7NqLkfjlPpbBu3E+c 8rJeYFiSWKmKZEqWIYgqRI4vl+Uv4PZ38LCTGjRrhBW+HdYKEoc9Jj0SWc0oOgbrMYufw aRzTARo5svqwWvTwlbDu1NnGqNIWhl/3wxIvdYsA0fXzLyMwkBccHcnhuGwXSfg8QuEWs uHN1NW5v5FR6vWhGOx+W52o36S5QZADVFkjsGoOsxuzzwxrcRg1UANeOcpPeo5xjx/w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=clvz8avz; arc=none smtp.remote-ip=91.218.175.80 X-Received: from mta0.migadu.com (out-80.mta0.migadu.com [91.218.175.80]) (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 527E8606A31B for <netdev@vger.kernel.org>; Fri, 23 Oct 2026 14:50:45 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 527E8606A31B X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Envelope-To: netdev@vger.kernel.org X-DKIM-Signature: a=rsa-sha256; bh=rM7gfWKY4WpRqwq90Mbl1M08Z1DYoWLMUw09JRN7Yrc=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1792767043; v=1; x=1793371843; b=clvz8avzEWPzhYA3pwKHhDcMrxkxId2j2bHp2crrKXGx0zDx3OBIdME6vlCDDoZRBhX2kN1Y 5YsW9OgeHQfMWBAdnMuXCoqWvBqooOmTLMREir63Cr6dG7LRqUY7VKupq+CUNrAhS/s9udg5Ozw 1iDIFL9L+njxKN/0PwccaJ+I= X-Envelope-To: netdev@vger.kernel.org X-Received: by smtp.migadu.com with ESMTPS id 17396e17f5dd6b28; Fri, 23 Oct 2026 14:50:43 +0000 X-Mizu-Trace-ID: 17396e17f5dd6b28 X-Migadu-Flow: FLOW_OUT X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list X-User-Agent: Mozilla Thunderbird X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, ncardwell@google.com, kuniyu@google.com, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org X-In-Reply-To: <tencent_31D2FFCCE76C50A695A1270151F825E90906@qq.com>