Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pkt_sched: fq: do not accept silly TCA_FQ_QUANTUM

As diagnosed by Florian :

If TCA_FQ_QUANTUM is set to 0x80000000, fq_deueue()
can loop forever in :

if (f->credit <= 0) {
f->credit += q->quantum;
goto begin;
}

... because f->credit is either 0 or -2147483648.

Let's limit TCA_FQ_QUANTUM to no more than 1 << 20 :
This max value should limit risks of breaking user setups
while fixing this bug.

Fixes: afe4fd062416 ("pkt_sched: fq: Fair Queue packet scheduler")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Diagnosed-by: Florian Westphal <fw@strlen.de>
Reported-by: syzbot+dc9071cc5a85950bdfce@syzkaller.appspotmail.com
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Eric Dumazet and committed by
David S. Miller
d9e15a27 b969fee1

+4 -2
+4 -2
net/sched/sch_fq.c
··· 786 786 if (tb[TCA_FQ_QUANTUM]) { 787 787 u32 quantum = nla_get_u32(tb[TCA_FQ_QUANTUM]); 788 788 789 - if (quantum > 0) 789 + if (quantum > 0 && quantum <= (1 << 20)) { 790 790 q->quantum = quantum; 791 - else 791 + } else { 792 + NL_SET_ERR_MSG_MOD(extack, "invalid quantum"); 792 793 err = -EINVAL; 794 + } 793 795 } 794 796 795 797 if (tb[TCA_FQ_INITIAL_QUANTUM])