BYTES_PER_KBIT is unsigned long, so ILP32 uses 32-bit unsigned math. Since v6.8, negative sendslope turns positive, breaking software CBS and cbs_dump() while high idleslope/port_rate overflow. Cast BYTES_PER_KBIT and speed in cbs_set_port_rate() to s64 to ensure signed 64-bit arithmetic on all architectures. Fixes: 000db9e9ad42 ("net/sched: cbs: Use units.h instead of the copy of a definition") Fixes: 397006ba5d91 ("net/sched: cbs: Fix integer overflow in cbs_set_port_rate()") Signed-off-by: Jack Wang <163w…@gmail.com> --- net/sched/sch_cbs.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c index 1c93469c56e3..cb14500a1f7c 100644 --- a/net/sched/sch_cbs.c +++ b/net/sched/sch_cbs.c @@ -335,7 +335,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q) speed = ecmd.base.speed; skip: - port_rate = speed * 1000 * BYTES_PER_KBIT; + port_rate = (s64)speed * 1000 * (s64)BYTES_PER_KBIT; atomic64_set(&q->port_rate, port_rate); netdev_dbg(dev, "cbs: set %s's port_rate to: %lld, linkspeed: %d\n", @@ -405,8 +405,8 @@ static int cbs_change(struct Qdisc *sch, struct nlattr *opt, /* Everything went OK, save the parameters used. */ WRITE_ONCE(q->hicredit, qopt->hicredit); WRITE_ONCE(q->locredit, qopt->locredit); - WRITE_ONCE(q->idleslope, qopt->idleslope * BYTES_PER_KBIT); - WRITE_ONCE(q->sendslope, qopt->sendslope * BYTES_PER_KBIT); + WRITE_ONCE(q->idleslope, qopt->idleslope * (s64)BYTES_PER_KBIT); + WRITE_ONCE(q->sendslope, qopt->sendslope * (s64)BYTES_PER_KBIT); WRITE_ONCE(q->offload, qopt->offload); return 0; @@ -475,8 +475,8 @@ static int cbs_dump(struct Qdisc *sch, struct sk_buff *skb) opt.hicredit = READ_ONCE(q->hicredit); opt.locredit = READ_ONCE(q->locredit); - opt.sendslope = div64_s64(READ_ONCE(q->sendslope), BYTES_PER_KBIT); - opt.idleslope = div64_s64(READ_ONCE(q->idleslope), BYTES_PER_KBIT); + opt.sendslope = div64_s64(READ_ONCE(q->sendslope), (s64)BYTES_PER_KBIT); + opt.idleslope = div64_s64(READ_ONCE(q->idleslope), (s64)BYTES_PER_KBIT); opt.offload = READ_ONCE(q->offload); if (nla_put(skb, TCA_CBS_PARMS, sizeof(opt), &opt))
-- 2.53.0