netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manas Ghandat <ghandatmanas@gmail.com>
To: stephen@networkplumber.org
Cc: xiyou.wangcong@gmail.com, Jiri Pirko <jiri@resnulli.us>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: net/sched: Fix divide error in tabledist
Date: Thu, 11 Dec 2025 23:36:32 +0530	[thread overview]
Message-ID: <f69b2c8f-8325-4c2e-a011-6dbc089f30e4@gmail.com> (raw)

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
Fixes: ec8e0e3d7ade ("net/sched: Restrict conditions for adding 
duplicating netems to qdisc tree")
Reported-by: Manas Ghandat <ghandatmanas@gmail.com>
Signed-off-by: Manas Ghandat <ghandatmanas@gmail.com>
---
net/sched/sch_netem.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
index 32a5f3304046..1a2b498ada83 100644
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -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
*/
-- 
2.43.0



             reply	other threads:[~2025-12-11 18:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-11 18:06 Manas Ghandat [this message]
2025-12-12  8:18 ` net/sched: Fix divide error in tabledist Stephen Hemminger
2025-12-12 15:17   ` Manas Ghandat
2025-12-17 18:27     ` Manas Ghandat
2025-12-21 17:03       ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f69b2c8f-8325-4c2e-a011-6dbc089f30e4@gmail.com \
    --to=ghandatmanas@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stephen@networkplumber.org \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).