Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 94ac4a4d authored by Eric Dumazet's avatar Eric Dumazet Committed by Greg Kroah-Hartman
Browse files

pkt_sched: fq: do not accept silly TCA_FQ_QUANTUM



[ Upstream commit d9e15a2733067c9328fb56d98fe8e574fa19ec31 ]

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: afe4fd06 ("pkt_sched: fq: Fair Queue packet scheduler")
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Diagnosed-by: default avatarFlorian Westphal <fw@strlen.de>
Reported-by: default avatar <syzbot+dc9071cc5a85950bdfce@syzkaller.appspotmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 77b07bbf
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -735,11 +735,13 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt,
	if (tb[TCA_FQ_QUANTUM]) {
		u32 quantum = nla_get_u32(tb[TCA_FQ_QUANTUM]);

		if (quantum > 0)
		if (quantum > 0 && quantum <= (1 << 20)) {
			q->quantum = quantum;
		else
		} else {
			NL_SET_ERR_MSG_MOD(extack, "invalid quantum");
			err = -EINVAL;
		}
	}

	if (tb[TCA_FQ_INITIAL_QUANTUM])
		q->initial_quantum = nla_get_u32(tb[TCA_FQ_INITIAL_QUANTUM]);