Merge branch 'tcp-fix-a-few-divide-by-zero-in-congestion-control-modules'

Jiayuan Chen says:

====================
tcp: fix a few divide-by-zero in congestion control modules

Patch 1 and 2 were reported by VEGA <vega@nebusec.ai>.

Patch 3 was found while reviewing the other TCP congestion control
modules for the same kind of divide-by-zero on module parameters.

Target net-next since it is not a big problem.

v2: https://lore.kernel.org/netdev/20261001112948.322463-1-jiayuan.chen@linux.dev/
v1: https://lore.kernel.org/netdev/20260930100937.206377-1-jiayuan.chen@linux.dev/
====================

Link: https://patch.msgid.link/20261008092641.140777-1-jiayuan.chen@linux.dev
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
Paolo Abeni 2026-10-13 15:17:57 +02:00
commit 59e344304c
3 changed files with 38 additions and 6 deletions

View File

@ -27,15 +27,25 @@
*/
static int fast_convergence = 1;
static int max_increment = 16;
static unsigned int max_increment = 16;
static int low_window = 14;
static int beta = 819; /* = 819/1024 (BICTCP_BETA_SCALE) */
static int initial_ssthresh;
static int smooth_part = 20;
static int max_increment_set(const char *val, const struct kernel_param *kp)
{
return param_set_uint_minmax(val, kp, 1, INT_MAX);
}
static const struct kernel_param_ops max_increment_ops = {
.set = max_increment_set,
.get = param_get_uint,
};
module_param(fast_convergence, int, 0644);
MODULE_PARM_DESC(fast_convergence, "turn on/off fast convergence");
module_param(max_increment, int, 0644);
module_param_cb(max_increment, &max_increment_ops, &max_increment, 0644);
MODULE_PARM_DESC(max_increment, "Limit on increment allowed during binary search");
module_param(low_window, int, 0644);
MODULE_PARM_DESC(low_window, "lower bound on congestion window (for TCP friendliness)");

View File

@ -500,16 +500,26 @@ static const struct btf_kfunc_id_set tcp_cubic_kfunc_set = {
static int __init cubictcp_register(void)
{
int b = READ_ONCE(beta);
int ret;
BUILD_BUG_ON(sizeof(struct bictcp) > ICSK_CA_PRIV_SIZE);
if (b < 0 || b >= BICTCP_BETA_SCALE ||
bic_scale <= 0 || bic_scale > INT_MAX / 10) {
pr_err("tcp_cubic: invalid beta %d or bic_scale %d\n",
b, bic_scale);
return -EINVAL;
}
/* Precompute a bunch of the scaling factors that are used per-packet
* based on SRTT of 100ms
*/
beta_scale = 8*(BICTCP_BETA_SCALE+beta) / 3
/ (BICTCP_BETA_SCALE - beta);
beta_scale = 8 * (BICTCP_BETA_SCALE + b) / 3
/ (BICTCP_BETA_SCALE - b);
/* bictcp_update() needs (cwnd * beta_scale) >> 3 to be >= 1 */
beta_scale = max(beta_scale, 8U);
cube_rtt_scale = (bic_scale * 10); /* 1024*c/rtt */

View File

@ -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 */