Skip to content

Commit df4953e

Browse files
edumazetdavem330
authored andcommitted
sch_sfq: validate silly quantum values
syzbot managed to set up sfq so that q->scaled_quantum was zero, triggering an infinite loop in sfq_dequeue() More generally, we must only accept quantum between 1 and 2^18 - 7, meaning scaled_quantum must be in [1, 0x7FFF] range. Otherwise, we also could have a loop in sfq_dequeue() if scaled_quantum happens to be 0x8000, since slot->allot could indefinitely switch between 0 and 0x8000. Fixes: eeaeb06 ("sch_sfq: allow big packets and be fair") Signed-off-by: Eric Dumazet <[email protected]> Reported-by: [email protected] Cc: Jason A. Donenfeld <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cf7fc3a commit df4953e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

net/sched/sch_sfq.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,15 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt)
637637
if (ctl->divisor &&
638638
(!is_power_of_2(ctl->divisor) || ctl->divisor > 65536))
639639
return -EINVAL;
640+
641+
/* slot->allot is a short, make sure quantum is not too big. */
642+
if (ctl->quantum) {
643+
unsigned int scaled = SFQ_ALLOT_SIZE(ctl->quantum);
644+
645+
if (scaled <= 0 || scaled > SHRT_MAX)
646+
return -EINVAL;
647+
}
648+
640649
if (ctl_v1 && !red_check_params(ctl_v1->qth_min, ctl_v1->qth_max,
641650
ctl_v1->Wlog))
642651
return -EINVAL;

0 commit comments

Comments
 (0)