[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <0750BA89-01A1-4126-9BEF-2C6AC607A5BD@gmail.com>
Date: Thu, 2 Jan 2020 23:58:02 +0200
From: Jonathan Morton <chromatix99@...il.com>
To: Wen Yang <wenyang@...ux.alibaba.com>
Cc: Toke Høiland-Jørgensen <toke@...e.dk>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
cake@...ts.bufferbloat.net,
Kevin Darbyshire-Bryant <ldir@...byshire-bryant.me.uk>,
Cong Wang <xiyou.wangcong@...il.com>,
"David S . Miller" <davem@...emloft.net>
Subject: Re: [Cake] [PATCH] sch_cake: avoid possible divide by zero in
cake_enqueue()
> On 2 Jan, 2020, at 11:21 am, Wen Yang <wenyang@...ux.alibaba.com> wrote:
>
> The variables 'window_interval' is u64 and do_div()
> truncates it to 32 bits, which means it can test
> non-zero and be truncated to zero for division.
> The unit of window_interval is nanoseconds,
> so its lower 32-bit is relatively easy to exceed.
> Fix this issue by using div64_u64() instead.
That might actually explain a few things. I approve.
Honestly the *correct* fix is for the compiler to implement division in a way that doesn't require substituting it with function calls. As this shows, it's error-prone to do this manually.
- Jonathan Morton
Powered by blists - more mailing lists