[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200106141039.204089-1-edumazet@google.com>
Date: Mon, 6 Jan 2020 06:10:39 -0800
From: Eric Dumazet <edumazet@...gle.com>
To: "David S . Miller" <davem@...emloft.net>
Cc: netdev <netdev@...r.kernel.org>,
Eric Dumazet <edumazet@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>,
Florian Westphal <fw@...len.de>,
syzbot+dc9071cc5a85950bdfce@...kaller.appspotmail.com
Subject: [PATCH net] 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@...gle.com>
Diagnosed-by: Florian Westphal <fw@...len.de>
Reported-by: syzbot+dc9071cc5a85950bdfce@...kaller.appspotmail.com
---
net/sched/sch_fq.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
index ff4c5e9d0d7778d86f20f4bd67cc627eed0713d9..a5a295477eccd52952e26e2ce121315341dddd0f 100644
--- a/net/sched/sch_fq.c
+++ b/net/sched/sch_fq.c
@@ -786,10 +786,12 @@ 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])
--
2.24.1.735.g03f4e72817-goog
Powered by blists - more mailing lists