linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte
@ 2019-09-03  1:08 Gustavo A. R. Silva
  2019-09-03  1:20 ` Vladimir Oltean
  2019-09-03  7:19 ` Eric Dumazet
  0 siblings, 2 replies; 7+ messages in thread
From: Gustavo A. R. Silva @ 2019-09-03  1:08 UTC (permalink / raw)
  To: Jamal Hadi Salim, Cong Wang, Jiri Pirko, David S. Miller,
	Vladimir Oltean
  Cc: netdev, linux-kernel, Gustavo A. R. Silva

Add suffix LL to constant 1000 in order to avoid a potential integer
overflow and give the compiler complete information about the proper
arithmetic to use. Notice that this constant is being used in a context
that expects an expression of type s64, but it's currently evaluated
using 32-bit arithmetic.

Addresses-Coverity-ID: 1453459 ("Unintentional integer overflow")
Fixes: f04b514c0ce2 ("taprio: Set default link speed to 10 Mbps in taprio_set_picos_per_byte")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 net/sched/sch_taprio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 8d8bc2ec5cd6..956f837436ea 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -966,7 +966,7 @@ static void taprio_set_picos_per_byte(struct net_device *dev,
 
 skip:
 	picos_per_byte = div64_s64(NSEC_PER_SEC * 1000LL * 8,
-				   speed * 1000 * 1000);
+				   speed * 1000LL * 1000);
 
 	atomic64_set(&q->picos_per_byte, picos_per_byte);
 	netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",
-- 
2.23.0


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

end of thread, other threads:[~2019-09-05 21:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-03  1:08 [PATCH] net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte Gustavo A. R. Silva
2019-09-03  1:20 ` Vladimir Oltean
2019-09-03  7:19 ` Eric Dumazet
2019-09-03 10:12   ` Vladimir Oltean
2019-09-03 21:26     ` Vinicius Costa Gomes
2019-09-05 20:47       ` Vladimir Oltean
2019-09-05 21:03         ` Gomes, Vinicius

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).