summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorVladimir Oltean <olteanv@gmail.com>2019-09-29 02:01:39 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-07 18:58:19 +0200
commit4e71bbe0fdc87c33c15053ccca27ac8917126e2c (patch)
treeb1d8aa56bce6b0763468f8802a076a0793191bcb /net
parenta087259d42bac4fcf1b6fe8c7577f10302ecd876 (diff)
downloadlinux-stable-4e71bbe0fdc87c33c15053ccca27ac8917126e2c.tar.gz
linux-stable-4e71bbe0fdc87c33c15053ccca27ac8917126e2c.tar.bz2
linux-stable-4e71bbe0fdc87c33c15053ccca27ac8917126e2c.zip
net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte
[ Upstream commit 68ce6688a5baefde30914fc07fc27292dbbe8320 ] The speed divisor is used in a context expecting an s64, but it is evaluated using 32-bit arithmetic. To avoid that happening, instead of multiplying by 1,000,000 in the first place, simplify the fraction and do a standard 32 bit division instead. Fixes: f04b514c0ce2 ("taprio: Set default link speed to 10 Mbps in taprio_set_picos_per_byte") Reported-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Vinicius Costa Gomes <vinicius.gomes@intel.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/sched/sch_taprio.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/net/sched/sch_taprio.c b/net/sched/sch_taprio.c
index 11c2873ec68b..f3f959f5458b 100644
--- a/net/sched/sch_taprio.c
+++ b/net/sched/sch_taprio.c
@@ -672,8 +672,7 @@ static void taprio_set_picos_per_byte(struct net_device *dev,
speed = ecmd.base.speed;
skip:
- picos_per_byte = div64_s64(NSEC_PER_SEC * 1000LL * 8,
- speed * 1000 * 1000);
+ picos_per_byte = (USEC_PER_SEC * 8) / speed;
atomic64_set(&q->picos_per_byte, picos_per_byte);
netdev_dbg(dev, "taprio: set %s's picos_per_byte to: %lld, linkspeed: %d\n",