From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 7BACF36403C for ; Wed, 12 Aug 2026 18:02:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786557781; cv=none; b=aZXazLpaGo2Xn6oZVaIWCs/uXNTZtiIUztXLMlo7Z47kVNMXEfapwrp8BJXK4P906PUA+UmJ9DyzkDY7QWrIEilmlgi4mu88LHaqLfxGmcS0p2sY2SHTfqK+3npw6UqY+XwY+rXoqgm08qULZXwg5cFP8wEipQnMofSc3SGP4i8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786557781; c=relaxed/simple; bh=m5CeT8WhAzSjCBjp1LJg5899gJdAwkBeQxj42ojzn9E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=FVnswhUTtNsXpEPoFwtLX2i3zBNsXMNd39Z17iduCOgZp8eSjQ2QHxcSULGiSsaHheA2m/JszaallWGvAY8hYrqcIYGsTAhdsnpuTkZtUYFQahTWBUv2a4iBI7ls+OrEahpAnCMCysB9TbEa8ain54wo621ziRYdNpz2/ZXrPC4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com; spf=none smtp.mailfrom=mojatatu.com; dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.b=Kx5xSU3o; arc=none smtp.client-ip=209.85.214.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=mojatatu.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=mojatatu.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=mojatatu.com header.i=@mojatatu.com header.b="Kx5xSU3o" Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2cfff5f88dbso15507415ad.3 for ; Wed, 12 Aug 2026 11:02:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu.com; s=google; t=1786557778; x=1787162578; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=yCF6tNyL3eGwCWXz/OETIKl/yai950rhoZA+gNdH5hY=; b=Kx5xSU3oo3tCPEd9gPq8xABH/tNAglrdNEqpWB/3RExrgZ5oAB8Zoey90R3FoU2gTU ULCxD6FaodxVLAEkX6EsxZVKGNT7cNH7vFWQsLvivooy8Ts3j3lVp+vExXV3iNrfV3Wh 5F9UDOdZr18BWp8sM/Dm1aTOfmiXa/C8xRKXc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786557778; x=1787162578; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=yCF6tNyL3eGwCWXz/OETIKl/yai950rhoZA+gNdH5hY=; b=RKvryatFSf08aokAjvSg5Y0Dq+Gm3WJqMcImLTDwZlkVp2tJqhTshUnijMMctSAzkK 7p7tzvH4VoZMLnVfsQ/2lzJoXy4kEgnqn6tAW1R695UJerQxYbSdTUOAV5+mUuwj2ChE PBx5EPk/B+9+GrxGzm19aMEoM70wHdNYEhlOMOukGfXK+KCA7rXy0kqY9byzT6jONX08 LOeHjMC2yiNocvN4WKdItpM67XCDYEY7lss0+IsmhGH2bWDzhLGYDF7WOa8dOUnLtzcR 22rtUL60GR2VXQNwr6Une98Q/CcB24VLsj5KCcM3ZFla8BLBLQpXjv0ykyBHHzaPWuis 50sQ== X-Gm-Message-State: AOJu0Yw37EVPc8trqJ0MWHi8Y3Uin8y80CutHbRgBni8knzQNUqu8x5T CaqtQp97h6oMsOjQKmu41vH+4BoHebFYl5shqTL15/p0kAsyeFjb3+PFXE/UGAqd1A== X-Gm-Gg: AR+sD12m/EXBQoS1D6yE1asqc9UzCm2vQVMdxWnkhJOOo89Vo+OgoLN7Bwujgzuy59V lDCsti8oj2beFp4O0aohYOm9IRUKceTiPJp7tGBWqwfeSuWt/LnUDt1GAS9lOhuhQMWdeePTHXc c2VyiypVmKIcr0nNd2DLPkRBbyW7Z8RvSPVD4NTgnokLw+O+kuyK/BAbaqMbLgqV9HVVxxgHY7K LGF1Qd/5w34E0/Fv2ehh88IPigV3cxchJkrBII4VRF2WvSX6I9xUMpaEhJHFhEon4KNPzWcZvzW FLxKeHqAkx8BGNORPyuEIyaYopOlaBhiXzbCsG/JRKYuONj/elPi6RLgCZuQBGBnsj0S26FSPqB BNtNUj/MKEVRAhSfTm1s4KJHrCuwmMnmMgDIqAUV9udEgVI9QUAm1068OtArkmFgcDDy32xSfgY zrQS1TjCCL1Q2IKBlcl9B3SmiQN7rw+bBAig4xo2byO4IyiYShbQc1rw/7Uh2jYIWmCwUmEg== X-Received: by 2002:a17:90b:2248:b0:37f:c97a:939f with SMTP id 98e67ed59e1d1-3931e05f926mr30047a91.7.1786557777645; Wed, 12 Aug 2026 11:02:57 -0700 (PDT) Received: from ?IPV6:2804:14d:5c54:4d67::2000? ([2804:14d:5c54:4d67::2000]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3931d80306asm49164a91.0.2026.08.12.11.02.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 12 Aug 2026 11:02:57 -0700 (PDT) Message-ID: <56e61c75-1041-4107-bef3-5029c8fdfd74@mojatatu.com> Date: Wed, 12 Aug 2026 15:02:52 -0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net v2] net/sched: cbs: perform rate conversions in signed 64-bit arithmetic To: Jack Wang <163wangjack@gmail.com>, netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Vinicius Costa Gomes , Jamal Hadi Salim , Jiri Pirko , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Elena Salomatkina References: <20260812100044.38040-1-163wangjack@gmail.com> Content-Language: en-US From: Victor Nogueira In-Reply-To: <20260812100044.38040-1-163wangjack@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hi! On 12/08/2026 07:00, Jack Wang wrote: > cbs_set_port_rate() and cbs_change() multiply link rates and slope values > by BYTES_PER_KBIT, an unsigned long constant. On 32-bit architectures, > the multiplications therefore take place in 32-bit unsigned arithmetic > before the results are assigned to s64 fields. > > For port rates above approximately 34.36 Gbit/s this wraps port_rate. > The same conversion turns a negative sendslope into a large positive > value, reversing the CBS credit adjustment. This affects software CBS; > port_rate is also refreshed on NETDEV_UP and NETDEV_CHANGE notifications. > > Cast the first operand of each multiplication to s64 so all intermediate > operations use signed 64-bit arithmetic and preserve the value's sign on > every architecture > > Also reject a non-positive idleslope. A negative idleslope can arm the > watchdog in the past and busy-loop. > > Fixes: 585d763af09c ("net/sched: Introduce Credit Based Shaper (CBS) qdisc") > Fixes: 397006ba5d918 ("net/sched: cbs: Fix integer overflow in cbs_set_port_rate()") > > Signed-off-by: Jack Wang <163wangjack@gmail.com> > --- > v2: > - Reject a non-positive idleslope to prevent scheduling the watchdog in > the past. > [...] > net/sched/sch_cbs.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c > index 1c93469c56e3..e960c8e01ef4 100644 > --- a/net/sched/sch_cbs.c > +++ b/net/sched/sch_cbs.c > [...] > @@ -392,6 +392,10 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt, > } > > qopt = nla_data(tb[TCA_CBS_PARMS]); > + if (qopt->idleslope <= 0) { > + NL_SET_ERR_MSG(extack, "Idleslope must be greater than zero"); > + return -EINVAL; > + } Unfortunately this is breaking tdc because it's forbidding an idleslope of 0: # Test 1820: Create CBS with default setting # exit: 2 # exit: 0 # Error: Idleslope must be greater than zero. Please don't forget to run tdc before sending tc-related patches. cheers, Victor