Re: [PATCH net-next 2/6] net/sched: netem: check for invalid slot range
From: Jakub Kicinski
Date: Mon Mar 30 2026 - 20:35:31 EST
On Sat, 28 Mar 2026 11:26:03 -0700 Stephen Hemminger wrote:
> Reject slot configuration where min_delay exceeds max_delay.
> The delay range computation in get_slot_next() underflows in
> this case, producing bogus results.
>
> Fixes: 0a9fe5c375b5 ("netem: slotting with non-uniform distribution")
>
spurious new line, but something either is a fix, gets a Fixes tag
and goes to net, or it's not a fix and goes to net-next. No fixes
in net-next please.
> Signed-off-by: Stephen Hemminger <stephen@xxxxxxxxxxxxxxxxxx>
> ---
> net/sched/sch_netem.c | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/net/sched/sch_netem.c b/net/sched/sch_netem.c
> index 73d0e85eeadc..de22d754cb79 100644
> --- a/net/sched/sch_netem.c
> +++ b/net/sched/sch_netem.c
> @@ -831,6 +831,17 @@ static int get_dist_table(struct disttable **tbl, const struct nlattr *attr,
> return 0;
> }
>
> +static int validate_slot(const struct nlattr *attr, struct netlink_ext_ack *extack)
> +{
> + const struct tc_netem_slot *c = nla_data(attr);
> +
> + if (c->min_delay > c->max_delay) {
> + NL_SET_ERR_MSG(extack, "slot min delay greater than max delay");
This wants _ATTR ?
> + return -EINVAL;
> + }
> + return 0;
> +}
> +
> static void get_slot(struct netem_sched_data *q, const struct nlattr *attr)
> {
> const struct tc_netem_slot *c = nla_data(attr);
> @@ -1045,6 +1056,12 @@ static int netem_change(struct Qdisc *sch, struct nlattr *opt, struct netlink_ex
> goto table_free;
> }
>
> + if (tb[TCA_NETEM_SLOT]) {
> + ret = validate_slot(tb[TCA_NETEM_SLOT], extack);
> + if (ret)
> + goto table_free;
> + }