From: Eric Dumazet Date: Wed, 18 Sep 2019 15:05:39 +0000 (-0700) Subject: sch_netem: fix a divide by zero in tabledist() X-Git-Tag: baikal/aarch64/sdk6.1~10878^2~75 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=bf58239c1baa1914bf0a50401a77c5a5a0788c84;p=kernel.git sch_netem: fix a divide by zero in tabledist() syzbot managed to crash the kernel in tabledist() loading an empty distribution table. t = dist->table[rnd % dist->size]; Simply return an error when such load is attempted. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Eric Dumazet Reported-by: syzbot Signed-off-by: Jakub Kicinski --- diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c index b17f2ed970e29..f5cb35e550f8d 100644 --- a/net/sched/sch_netem.c +++ b/net/sched/sch_netem.c @@ -777,7 +777,7 @@ static int get_dist_table(struct Qdisc *sch, struct disttable **tbl, struct disttable *d; int i; - if (n > NETEM_DIST_MAX) + if (!n || n > NETEM_DIST_MAX) return -EINVAL; d = kvmalloc(sizeof(struct disttable) + n * sizeof(s16), GFP_KERNEL);