• Wen Yang's avatar
    sch_cake: avoid possible divide by zero in cake_enqueue() · 68aab823
    Wen Yang authored
    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: 7298de9c ("sch_cake: Add ingress mode")
    Signed-off-by: default avatarWen Yang <wenyang@linux.alibaba.com>
    Cc: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
    Cc: Toke Høiland-Jørgensen <toke@redhat.com>
    Cc: David S. Miller <davem@davemloft.net>
    Cc: Cong Wang <xiyou.wangcong@gmail.com>
    Cc: cake@lists.bufferbloat.net
    Cc: netdev@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Acked-by: default avatarToke Høiland-Jørgensen <toke@toke.dk>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    68aab823
sch_cake.c 78 KB