Skip to contentSkip to conversation

sch_hhf: ensure quantum and hhf_non_hh_weight are non-zero

PATCH In review Cong Wang 2 participants 2 messages Sep 8, 2019 – Sep 10, 2019

Subsystems (3)
lore
Share & tools
lore

Cong Wang

author
#0 lore raw

PATCH 1/1 sch_hhf: ensure quantum and hhf_non_hh_weight are non-zero

In case of TCA_HHF_NON_HH_WEIGHT or TCA_HHF_QUANTUM is zero, it would make no progress inside the loop in hhf_dequeue() thus kernel would get stuck.

Fix this by checking this corner case in hhf_change().

Fixes 10239edf86f1 ("net-qdisc-hhf: Heavy-Hitter Filter (HHF) qdisc")
Reported-by [email protected]
Reported-by [email protected]
Reported-by [email protected]
Cc Jamal Hadi Salim <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Terry Lam <[email protected]>
---
 net/sched/sch_hhf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/sch_hhf.c +1 -1
index cee6971c1c82..23cd1c873a2c 100644
@@ -531,7 +531,7 @@ static int hhf_change(struct Qdisc *sch, struct nlattr *opt,
 		new_hhf_non_hh_weight = nla_get_u32(tb[TCA_HHF_NON_HH_WEIGHT]);
 
 	non_hh_quantum = (u64)new_quantum * new_hhf_non_hh_weight;
-	if (non_hh_quantum > INT_MAX)
+	if (non_hh_quantum == 0 || non_hh_quantum > INT_MAX)
 		return -EINVAL;
 
 	sch_tree_lock(sch);
Signature · 1 line
2.21.0
maintainer
#1 lore raw

From: Cong Wang <[email protected]>
Date: Sun, 8 Sep 2019 13:40:51 -0700

Quoted 6 lines

In case of TCA_HHF_NON_HH_WEIGHT or TCA_HHF_QUANTUM is zero, it would make no progress inside the loop in hhf_dequeue() thus kernel would get stuck.

Fix this by checking this corner case in hhf_change().

Quoted 8 lines
Fixes 10239edf86f1 ("net-qdisc-hhf: Heavy-Hitter Filter (HHF) qdisc")
Reported-by [email protected]
Reported-by [email protected]
Reported-by [email protected]
Cc Jamal Hadi Salim <[email protected]>
Cc Jiri Pirko <[email protected]>
Cc Terry Lam <[email protected]>

Applied and queued up for -stable.