mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Victor Nogueira <victor@mojatatu.com>
To: Jack Wang <163wangjack@gmail.com>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Vinicius Costa Gomes <vinicius.gomes@intel.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Elena Salomatkina <esalomatkina@ispras.ru>
Subject: Re: [PATCH net v2] net/sched: cbs: perform rate conversions in signed 64-bit arithmetic
Date: Wed, 12 Aug 2026 15:02:52 -0300	[thread overview]
Message-ID: <56e61c75-1041-4107-bef3-5029c8fdfd74@mojatatu.com> (raw)
In-Reply-To: <20260812100044.38040-1-163wangjack@gmail.com>

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

  reply	other threads:[~2026-08-12 18:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-12 10:00 Jack Wang
2026-08-12 18:02 ` Victor Nogueira [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-06 15:49 [PATCH] " Jack Wang
2026-08-12  8:02 ` [PATCH net v2] " Jack Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56e61c75-1041-4107-bef3-5029c8fdfd74@mojatatu.com \
    --to=victor@mojatatu.com \
    --cc=163wangjack@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=esalomatkina@ispras.ru \
    --cc=horms@kernel.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vinicius.gomes@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®