🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #6442

Re: [PATCH net] tcp: limit tcp_tso_rtt_log to a valid shift count

#6442
From: Jiayuan Chen
Date: Thu, 22 Oct 2026 12:50
94 lines
11665 bytes
On 10/22/26 8:27 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>
> ---
>   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..e95431140 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;
> @@ -778,6 +779,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	= "ip_early_demux",


Wait a minute, is my tree too old, or did you land tcp_tso_rtt_log_max
in the wrong place?

It looks like you are adding it to the ip_dynaddr entry. tcp_tso_rtt_log?

     {
         .procname    = "ip_dynaddr",
         .data        = &init_net.ipv4.sysctl_ip_dynaddr,
         .maxlen        = sizeof(u8),
         .mode        = 0644,
         .proc_handler    = proc_dou8vec_minmax,
     },
     {
         .procname    = "ip_early_demux",
         .data        = &init_net.ipv4.sysctl_ip_early_demux,
         .maxlen        = sizeof(u8),
         .mode        = 0644,
         .proc_handler    = proc_dou8vec_minmax,
     },

> base-commit: f4377bf85887f57b59abb5479f7660a81ffe4449
Technical Details
Message-ID: <f97b13ca-90b2-4bac-91bb-70c9d26095f9@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-350578-linux-kernel-netdev=dewy.ru
References: <tencent_53CDCF8AA0022B75CF72A294CB9993D2FF07@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-350578-linux-kernel-netdev=dewy.ru
From: jiayuan.chen@linux.dev (Jiayuan Chen)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net] tcp: limit tcp_tso_rtt_log to a valid shift count
Date: Thu, 22 Oct 2026 20:50:57 +0800
Organization: Usenet Network
Message-ID: <f97b13ca-90b2-4bac-91bb-70c9d26095f9@linux.dev>
References: <tencent_53CDCF8AA0022B75CF72A294CB9993D2FF07@qq.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="212118"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:9ERE+VN6EeTGdttU7G9qv1Hqf2M= sha256:juIId/wB68Knik0wmeaQyGmeATT56m0KkX+d201ZFwk=
	sha1:Pr5jGEj72ze2GQS2XhzrlCfw1H8= sha256:JyPNOn+8Ew41euULAn2HdYp5FnpKhxPLurOAWtG4foU=
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 5FBAB111282; Thu, 22 Oct 2026 15:52:07 +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 OTJ1xWarZBBp;
	Thu, 22 Oct 2026 15:52:02 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-350578-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])
	by mail.dewy.ru (Postfix) with ESMTPS id 36C751111F7; Thu, 22 Oct 2026 15:51:54 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sea.lore.kernel.org (Postfix) with ESMTP id 9597528BCA; Thu, 22 Oct 2026 12:51:03 +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=1792673463;
	b=kO2Yv41HV4l0FU1+iVcXbgQMW4iEXnn1h36tEu51S/5gvbBg42ip/56a51D6fskdm/Z3
	 lN7FXRQC8KEGL3o8WvRU8Ied0TSESm9mgm5UBnNxiqfdK4ToLhrblw0dtDF7Rrqh2WXd9
	 A1rR1Id65RgznAjLH1Up+96N77PJKifuWpBc8FX/GJhr6iHRoulR7KAAXcxVFaKLGrImy
	 16btT/81CM1ayIAsD0FOHHMKneaol71UffVlHRkNeAETPoqCIQVsax4QWctOujyV0qJDO
	 NZ1KCZLIypkhDWFtrczgbDUahgyS1dZBIbJth5COjpki1+POASngOCIdu8UC55V16yg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792673463;
	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:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=6jubY5/jjzQ8tuOwzuRmqBDvQIqz0kDbItlUUnX+i5w=;
	b=1L2x0FFlE68JRT6PHyxLZ0sk00M3I+JODIBez4AuGqY8y2aFFtq9uT2jN5+3n2kJPSlw
	 5Tw7pAn6zDpoW4fjZi/r0Eok5QrSCYgxyJRYDvkEvD62h35T9w6mNFzCX1R+A9CceU487
	 bgmLncruXDFAfQ5EjhfB5X8n0lpoIGchMzjFEghJgGOPwHsmNSILWNsrpKCl7c+l7NLun
	 KS3hTcCBlmGGyDTF1X9Z+hQeXjHoJ6VekHo8DmR4X3I2Lep9HAVKj/iJ/4PcfsMX76yeX
	 ZpBsJu94JwVPgKHsg8iexV1P4x3lB59rU8sxhereYlfGJljevgfBP+JQ1Gl72nALpyw==
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=mFI8I6aR;
	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 68651606A31F;
	Thu, 22 Oct 2026 12:51:03 +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=mFI8I6aR
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.93
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1792673462;
	b=pH86wIUeFg4cKeU0SpGDiK5eERg/uH8zAiBwFFBwXHafDcA5wBQiX2JcT2P/oAkIh4Mh
	 oUJBT64E28KhCknIz1bcILLdRJSlZPAW/ZFyWk0MmsnjqCw1G8pDx4lTK7GmpHxhXAKqJ
	 fFxKZ/Xnb0QrHQYvJqHKjOCAXNb0QQjXGBUQfT7EurWztTP5dvarJo6FrsT46IPtfLdjd
	 VkRAm4/4FlpGAqphHTovFmrGuRIfwjL20phvaczzqVMl9jr1ibbizQRB7MXW5IFZK03bv
	 Ka/QsP70bk+vRpGbeK1d7V3xwkBxRUMgcg4b4u2OJimgU16LX34ndoX25kiRtEXg3TQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1792673462;
	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:References:From:In-Reply-To:Content-Type:
	 Content-Transfer-Encoding;
	bh=6jubY5/jjzQ8tuOwzuRmqBDvQIqz0kDbItlUUnX+i5w=;
	b=krpD6yqFmzvoQHv59WnLwyGhtxQnd4SWoa1NeRKWja9vThqEl+sHBbMFgDsjtz9J5Hgp
	 3cO6HTebz7NjDqrBlnarl5E/eO5lUI6lnhYry8PfKQLTAY+N8KZji4QxrUhlmAQEiv8Sq
	 WWe0om2zedPPbG1nJzjofcvnCv/95L1wDNSHsSbymKd5eJd72pUKbGotoMSHa0XkgHPme
	 0sFcSh17TJ+4MgU1t3CuJelfRr1yLfYBPctp4/JN+plCsxaeEmTnVvBb17KimKmArLwl9
	 uwyyjFeokzsoibYgwDi5b5QitSE2pCJ003A7GRm0VHI6N8ZiH8fgUas148MbUv/nu+Q==
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=mFI8I6aR;
	arc=none smtp.remote-ip=95.215.58.93
X-Received: from mta1.migadu.com (out-93.mta1.migadu.com [95.215.58.93])
	(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 C3391606A322
	for <netdev@vger.kernel.org>; Thu, 22 Oct 2026 12:51:01 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3391606A322
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=spKMJFioSCArVqJ02iuuvERXVsHVShBgPL1lZ41Z1f8=;
 c=simple/simple; d=linux.dev;
 h=from:to:subject:date:message-id:mime-version:content-type; s=key1;
 t=1792673460; v=1; x=1793278260;
 b=mFI8I6aRrnJRg/9r9ZgFyfwkum2XN1t9nuj6l1PK870EefnE1YTHNWFbmE2BfEuTcgjjikXV
 WYZI/GYX6kTwRwGzYNRxwdHWI6me3AmmpDac6qWmKXPj8Nhq6IJzLzp/0kLeg0/11JUzqiiL6ta
 yaVVe6w4y8/Nt2e5pSI517lY=
X-Envelope-To: netdev@vger.kernel.org
X-Received: by smtp.migadu.com with ESMTPS id 709fad6a2ba1a8cd;
	Thu, 22 Oct 2026 12:51:00 +0000
X-Mizu-Trace-ID: 709fad6a2ba1a8cd
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-In-Reply-To: <tencent_53CDCF8AA0022B75CF72A294CB9993D2FF07@qq.com>