]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net: sched: taprio: Fix potential integer overflow in taprio_set_picos_per_byte
authorVladimir Oltean <olteanv@gmail.com>
Sat, 28 Sep 2019 23:01:39 +0000 (02:01 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 7 Oct 2019 16:58:19 +0000 (18:58 +0200)
commit4e71bbe0fdc87c33c15053ccca27ac8917126e2c
treeb1d8aa56bce6b0763468f8802a076a0793191bcb
parenta087259d42bac4fcf1b6fe8c7577f10302ecd876
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>
net/sched/sch_taprio.c