Skip to content

Commit 5b5e1c2

Browse files
dmikandNipaLocal
authored andcommitted
openvswitch: fix band bucket value computation in ovs_meter_execute()
In ovs_meter_execute(), promote 'delta_ms' to 'long long int' to avoid possible integer overflow. It's assumed that'delta_ms' and 'band->rate' multiplication leads to overcomming UINT32_MAX. Compile tested only. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Dmitry Kandybka <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent 4b81261 commit 5b5e1c2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

net/openvswitch/meter.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,11 +594,11 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
594594
{
595595
long long int now_ms = div_u64(ktime_get_ns(), 1000 * 1000);
596596
long long int long_delta_ms;
597+
long long int delta_ms;
597598
struct dp_meter_band *band;
598599
struct dp_meter *meter;
599600
int i, band_exceeded_max = -1;
600601
u32 band_exceeded_rate = 0;
601-
u32 delta_ms;
602602
u32 cost;
603603

604604
meter = lookup_meter(&dp->meter_tbl, meter_id);
@@ -623,7 +623,7 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
623623
* wrap around below.
624624
*/
625625
delta_ms = (long_delta_ms > (long long int)meter->max_delta_t)
626-
? meter->max_delta_t : (u32)long_delta_ms;
626+
? meter->max_delta_t : long_delta_ms;
627627

628628
/* Update meter statistics.
629629
*/

0 commit comments

Comments
 (0)