Skip to contentSkip to conversation

net/sched: Fix divide error in tabledist

PATCH In review Manas 3 participants 5 messages Dec 22, 2025 – Feb 25

Subsystems (4)
lore
Share & tools
lore

Manas

author
#0 lore raw

PATCH v2 1/1 net/sched: Fix divide error in tabledist

Previously, a duplication check was added to ensure that a duplicating netem cannot exist in a tree with other netems. When check_netem_in_tree() fails after parameter updates, the qdisc structure is left in an inconsistent state with some new values applied but duplicate not updated. Move the tree validation check before modifying any qdisc parameters

v1 -> v2: Fix whitespace

---
 net/sched/sch_netem.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
net/sched/sch_netem.c +5 -6
index 32a5f3304046..1a2b498ada83 100644
@@ -1055,6 +1055,11 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,
 		q->loss_model = CLG_RANDOM;
 	}
 
+	ret = check_netem_in_tree(sch, qopt->duplicate, extack);
+	if (ret)
+		goto unlock;
+	q->duplicate = qopt->duplicate;
+
 	if (delay_dist)
 		swap(q->delay_dist, delay_dist);
 	if (slot_dist)
@@ -1068,12 +1073,6 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt,
 	q->counter = 0;
 	q->loss = qopt->loss;
 
-	ret = check_netem_in_tree(sch, qopt->duplicate, extack);
-	if (ret)
-		goto unlock;
-
-	q->duplicate = qopt->duplicate;
-
 	/* for compatibility with earlier versions.
 	 * if gap is set, need to assume 100% probability
 	 */
Signature · 1 line
2.43.0
#1 lore raw

Hi Manas,

Quoted 6 lines · Manas

Previously, a duplication check was added to ensure that a duplicating netem cannot exist in a tree with other netems. When check_netem_in_tree() fails after parameter updates, the qdisc structure is left in an inconsistent state with some new values applied but duplicate not updated. Move the tree validation check before modifying any qdisc parameters

We are reverting the check_netem_in_tree() code due to user-space breakage. I hope reverting it could also fix the bug you repported here?

See: https://lore.kernel.org/netdev/[email protected]/

Thanks!
Cong

#2 lore raw

Hi Cong,

Quoted 7 lines · Cong Wang

We are reverting the check_netem_in_tree() code due to user-space breakage. I hope reverting it could also fix the bug you repported here?

See: https://lore.kernel.org/netdev/[email protected]/

Thanks!
Cong

Reverting the above patch would fix the bug which I have reported.

#3 lore raw

Hi,

I just wanted an update since the patch has not been merged yet.

Quoted 13 lines · Manas Ghandat

Hi Cong,

Quoted 7 lines · Cong Wang

We are reverting the check_netem_in_tree() code due to user-space breakage. I hope reverting it could also fix the bug you repported here?

See: https://lore.kernel.org/netdev/[email protected]/

Thanks!
Cong

Reverting the above patch would fix the bug which I have reported.

maintainer
#4 lore raw
Quoted 5 lines · Manas Ghandat

Hi,

I just wanted an update since the patch has not been merged yet.

Patience please...

cheers,
jamal

Quoted 15 lines · Manas Ghandat
Quoted 13 lines

Hi Cong,

Quoted 7 lines · Cong Wang

We are reverting the check_netem_in_tree() code due to user-space breakage. I hope reverting it could also fix the bug you repported here?

See: https://lore.kernel.org/netdev/[email protected]/

Thanks!
Cong

Reverting the above patch would fix the bug which I have reported.