aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWen Yang <[email protected]>2020-01-02 17:21:43 +0800
committerDavid S. Miller <[email protected]>2020-01-02 16:34:28 -0800
commit68aab823c223646fab311f8a6581994facee66a0 (patch)
treeb0ca5b68fbeda17f190305cdae73670591f7887a
parentd8513df2598e5142f8a5c4724f28411936e1dfc7 (diff)
sch_cake: avoid possible divide by zero in cake_enqueue()
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. Fixes: 7298de9cd725 ("sch_cake: Add ingress mode") Signed-off-by: Wen Yang <[email protected]> Cc: Kevin Darbyshire-Bryant <[email protected]> Cc: Toke Høiland-Jørgensen <[email protected]> Cc: David S. Miller <[email protected]> Cc: Cong Wang <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Acked-by: Toke Høiland-Jørgensen <[email protected]> Signed-off-by: David S. Miller <[email protected]>
-rw-r--r--net/sched/sch_cake.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
index e0f40400f679..2277369feae5 100644
--- a/net/sched/sch_cake.c
+++ b/net/sched/sch_cake.c
@@ -1769,7 +1769,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
q->avg_window_begin));
u64 b = q->avg_window_bytes * (u64)NSEC_PER_SEC;
- do_div(b, window_interval);
+ b = div64_u64(b, window_interval);
q->avg_peak_bandwidth =
cake_ewma(q->avg_peak_bandwidth, b,
b > q->avg_peak_bandwidth ? 2 : 8);