Re: [PATCH net v3 7/7] net/sched: netem: fix slot delay calculation overflow
From: Simon Horman
Date: Sat Apr 04 2026 - 05:54:16 EST
On Thu, Apr 02, 2026 at 01:19:35PM -0700, Stephen Hemminger wrote:
> get_slot_next() computes a random delay between min_delay and
> max_delay using:
>
> get_random_u32() * (max_delay - min_delay) >> 32
>
> This overflows signed 64-bit arithmetic when the delay range exceeds
> approximately 2.1 seconds (2^31 nanoseconds), producing a negative
> result that effectively disables slot-based pacing. This is a
> realistic configuration for WAN emulation (e.g., slot 1s 5s).
>
> Use mul_u64_u32_shr() which handles the widening multiply without
> overflow.
>
> Fixes: 0a9fe5c375b5 ("netem: slotting with non-uniform distribution")
> Signed-off-by: Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx>
Reviewed-by: Simon Horman <horms@xxxxxxxxxx>