From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mta1.migadu.com (out-213.mta1.migadu.com [95.215.58.213]) (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 D28D63DDAFD for ; Wed, 30 Sep 2026 10:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.213 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790763046; cv=none; b=WnAgZ7uneIc25XuLAdtv8fdiEBP4sK9GGIz7bGWD7+a5O6EkNvatSGfmUqjcJNaLCeBl0ks8GBH4J3StLsptW8klrX+E90Pqko2zL4NAarz8QLvN4/267FZMUlOQccM1SNdjeOwRhzzT2EYWhbP9//O7yCCgKI5xKLLFkXArF/M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790763046; c=relaxed/simple; bh=iidkKtQQEYQe01Vdz7+B8AHkY74Ifx7+I4PpwJ4EoY4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lVgz77aFMZ2K062CY85XguxbJFMPBYxK91Io5Ma6+50YhfA+vBUpBizE40oc8TtNQsF6l3iP6IAZgTGJIBfj9PlZWKcV37l6vedldSmRuyRhongVuhaw3Co0k+2D6efdq9oeeSZbQxsS2K8H6V2bQ4yhZ1p86TmOSYcKZ2ncUFg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=rNQJxQ+x; arc=none smtp.client-ip=95.215.58.213 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="rNQJxQ+x" X-Envelope-To: linux-kernel@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=iidkKtQQEYQe01Vdz7+B8AHkY74Ifx7+I4PpwJ4EoY4=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1790763041; v=1; x=1791367841; b=rNQJxQ+x6UnVzCRzyc5aG9xYhLOFWx8iSiBp+C/0Z/cDXJbCcjyrQH1buoVJUCPiAGOFSlQL ZEQg1JYjQ6UdSk4uX0jgnRHg72QbKEFo2q+iWPunqRf2XPUPISmmxSMzuytvmL3RFxahDmonf3n xOYIgNuDjIVxA2L9UPhQKQ/E= X-Envelope-To: linux-kernel@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id 09c9286d23320e4d; Wed, 30 Sep 2026 10:10:31 +0000 X-Mizu-Trace-ID: 09c9286d23320e4d X-Migadu-Flow: FLOW_OUT From: Jiayuan Chen To: netdev@vger.kernel.org Cc: Jiayuan Chen , VEGA , Eric Dumazet , Neal Cardwell , Kuniyuki Iwashima , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , Stephen Hemminger , linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] tcp_hybla: fix divide by zero on rtt0 == 0 Date: Wed, 30 Sep 2026 18:09:31 +0800 Message-ID: <20260930100937.206377-3-jiayuan.chen@linux.dev> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260930100937.206377-1-jiayuan.chen@linux.dev> References: <20260930100937.206377-1-jiayuan.chen@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit rtt0 is the reference RTT in ms, so 0 makes no sense, and hybla_recalc_param() divides by it right from hybla_init(). Reject values below 1 when the parameter is written. Also cap it at U32_MAX / USEC_PER_MSEC, since rtt0 * USEC_PER_MSEC can wrap to 0 on 32-bit. An rtt0 above that (about 71 minutes) makes no sense anyway. Fixes: 835b3f0c0d7e ("[TCP]: Add TCP Hybla congestion control module.") Fixes: 740b0f1841f6 ("tcp: switch rtt estimations to usec resolution") Reported-by: VEGA Signed-off-by: Jiayuan Chen --- Target net-next since it is not a big problem. --- net/ipv4/tcp_hybla.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/net/ipv4/tcp_hybla.c b/net/ipv4/tcp_hybla.c index abd7d91807e54..b9b482180d30b 100644 --- a/net/ipv4/tcp_hybla.c +++ b/net/ipv4/tcp_hybla.c @@ -26,8 +26,20 @@ struct hybla { }; /* Hybla reference round trip time (default= 1/40 sec = 25 ms), in ms */ -static int rtt0 = 25; -module_param(rtt0, int, 0644); +static unsigned int rtt0 = 25; + +static int rtt0_set(const char *val, const struct kernel_param *kp) +{ + /* avoid rtt0 * USEC_PER_MSEC overflow */ + return param_set_uint_minmax(val, kp, 1, U32_MAX / USEC_PER_MSEC); +} + +static const struct kernel_param_ops rtt0_ops = { + .set = rtt0_set, + .get = param_get_uint, +}; + +module_param_cb(rtt0, &rtt0_ops, &rtt0, 0644); MODULE_PARM_DESC(rtt0, "reference rout trip time (ms)"); /* This is called to refresh values for hybla parameters */ -- 2.43.0