> -----Original Message-----
> From: Intel-wired-lan <[email protected]> On Behalf Of 
> Aleksandr Loktionov
> Sent: 20 March 2026 10:36
> To: [email protected]; Nguyen, Anthony L 
> <[email protected]>; Loktionov, Aleksandr 
> <[email protected]>
> Cc: [email protected]; Czapnik, Lukasz <[email protected]>
> Subject: [Intel-wired-lan] [PATCH iwl-next] ice: prevent integer overflow
>
> From: Lukasz Czapnik <[email protected]>
>
> In ice_sched_bw_to_rl_profile(), the loop over 64 bits computes the scheduler 
> timestamp rate as:
>
>  ts_rate = div64_long((s64)hw->psm_clk_freq,
>                       pow_result * ICE_RL_PROF_TS_MULTIPLIER);
>
> where pow_result = BIT_ULL(i). For large values of i, the product pow_result 
> * ICE_RL_PROF_TS_MULTIPLIER overflows u64 before being used as the divisor, 
> producing incorrect ts_rate values and potentially undefined behaviour.
>
> Fix this by pre-computing ts_freq = hw->psm_clk_freq / 
> ICE_RL_PROF_TS_MULTIPLIER once before the loop and then dividing only by 
> pow_result inside the loop. The division order avoids the overflow while 
> preserving the same mathematical result. Declare ts_freq as s64 to match the 
> type domain of the surrounding arithmetic and avoid a redundant cast at the 
> use site.
>
> While at it, scope the loop variable i to the for statement itself.
>
> Fixes: 1ddef455f4a8 ("ice: Add NDO callback to set the maximum per-queue 
> bitrate")
> Signed-off-by: Lukasz Czapnik <[email protected]>
> Signed-off-by: Aleksandr Loktionov <[email protected]>
> ---
> drivers/net/ethernet/intel/ice/ice_sched.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>

Tested-by: Rinitha S <[email protected]> (A Contingent worker at Intel)

Reply via email to