All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] openvswitch: meter: Use 64-bit arithmetic instead of 32-bit
@ 2018-01-31  4:55 Gustavo A. R. Silva
  2018-01-31 15:33   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2018-01-31  4:55 UTC (permalink / raw)
  To: Pravin B Shelar, David S. Miller
  Cc: netdev, dev, linux-kernel, Gustavo A. R. Silva

Add suffix LL to constant 1000 in order to give the compiler
complete information about the proper arithmetic to use. Notice
that this constant is used in a context that expects an expression
of type long long int (64 bits, signed).

The expression (band->burst_size + band->rate) * 1000 is currently
being evaluated using 32-bit arithmetic.

Addresses-Coverity-ID: 1461563 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/openvswitch/meter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/openvswitch/meter.c b/net/openvswitch/meter.c
index 3fbfc78..04b9428 100644
--- a/net/openvswitch/meter.c
+++ b/net/openvswitch/meter.c
@@ -488,7 +488,7 @@ bool ovs_meter_execute(struct datapath *dp, struct sk_buff *skb,
 		long long int max_bucket_size;
 
 		band = &meter->bands[i];
-		max_bucket_size = (band->burst_size + band->rate) * 1000;
+		max_bucket_size = (band->burst_size + band->rate) * 1000LL;
 
 		band->bucket += delta_ms * band->rate;
 		if (band->bucket > max_bucket_size)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] openvswitch: meter: Use 64-bit arithmetic instead of 32-bit
  2018-01-31  4:55 [PATCH] openvswitch: meter: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
@ 2018-01-31 15:33   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2018-01-31 15:33 UTC (permalink / raw)
  To: gustavo; +Cc: pshelar, netdev, dev, linux-kernel, garsilva

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Tue, 30 Jan 2018 22:55:33 -0600

> Add suffix LL to constant 1000 in order to give the compiler
> complete information about the proper arithmetic to use. Notice
> that this constant is used in a context that expects an expression
> of type long long int (64 bits, signed).
> 
> The expression (band->burst_size + band->rate) * 1000 is currently
> being evaluated using 32-bit arithmetic.
> 
> Addresses-Coverity-ID: 1461563 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] openvswitch: meter: Use 64-bit arithmetic instead of 32-bit
@ 2018-01-31 15:33   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2018-01-31 15:33 UTC (permalink / raw)
  To: gustavo-L1vi/lXTdts+Va1GwOuvDg
  Cc: dev-yBygre7rU0TnMu66kgdUjQ, netdev-u79uwXL29TY76Z2rM5mHXA,
	garsilva-L1vi/lXTdts+Va1GwOuvDg,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

From: "Gustavo A. R. Silva" <gustavo-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>
Date: Tue, 30 Jan 2018 22:55:33 -0600

> Add suffix LL to constant 1000 in order to give the compiler
> complete information about the proper arithmetic to use. Notice
> that this constant is used in a context that expects an expression
> of type long long int (64 bits, signed).
> 
> The expression (band->burst_size + band->rate) * 1000 is currently
> being evaluated using 32-bit arithmetic.
> 
> Addresses-Coverity-ID: 1461563 ("Unintentional integer overflow")
> Signed-off-by: Gustavo A. R. Silva <gustavo-L1vi/lXTdts+Va1GwOuvDg@public.gmane.org>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-01-31 15:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-31  4:55 [PATCH] openvswitch: meter: Use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-01-31 15:33 ` David Miller
2018-01-31 15:33   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.