[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aS630uTBI26gLBTZ@dcaratti.users.ipa.redhat.com>
Date: Tue, 2 Dec 2025 10:56:34 +0100
From: Davide Caratti <dcaratti@...hat.com>
To: Jamal Hadi Salim <jhs@...atatu.com>
Cc: davem@...emloft.net, kuba@...nel.org, edumazet@...gle.com,
pabeni@...hat.com, xiyou.wangcong@...il.com, jiri@...nulli.us,
netdev@...r.kernel.org, horms@...nel.org,
zdi-disclosures@...ndmicro.com, w@....eu, security@...nel.org,
tglx@...utronix.de, victor@...atatu.com
Subject: Re: [PATCH net] net/sched: ets: Always remove class from active list
before deleting in ets_qdisc_change
On Fri, Nov 28, 2025 at 03:52:53PM -0500, Jamal Hadi Salim wrote:
> Hi Davide,
>
> On Fri, Nov 28, 2025 at 12:25 PM Davide Caratti <dcaratti@...hat.com> wrote:
hello Jamal, thanks for your patience!
[...]
> > > diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c
> > > index 82635dd2cfa5..ae46643e596d 100644
> > > --- a/net/sched/sch_ets.c
> > > +++ b/net/sched/sch_ets.c
> > > @@ -652,7 +652,7 @@ static int ets_qdisc_change(struct Qdisc *sch, struct nlattr *opt,
> > > sch_tree_lock(sch);
> > >
> > > for (i = nbands; i < oldbands; i++) {
> > > - if (i >= q->nstrict && q->classes[i].qdisc->q.qlen)
> > > + if (cl_is_active(&q->classes[i]))
> > > list_del_init(&q->classes[i].alist);
> > > qdisc_purge_queue(q->classes[i].qdisc);
> > > }
> >
> > (nit)
> >
> > the reported problem is NULL dereference of q->classes[i].qdisc, then
> > probably the 'Fixes' tag is an hash precedent to de6d25924c2a ("net/sched: sch_ets: don't
> > peek at classes beyond 'nbands'"). My understanding is: the test on 'q->classes[i].qdisc'
> > is no more NULL-safe after 103406b38c60 ("net/sched: Always pass notifications when
> > child class becomes empty"). So we might help our friends planning backports with something like:
> >
> > Fixes: de6d25924c2a ("net/sched: sch_ets: don't peek at classes beyond 'nbands'")
> > Fixes: c062f2a0b04d ("net/sched: sch_ets: don't remove idle classes from the round-robin list")
> >
> > WDYT?
>
> I may be misreading your thought process, seems you are thinking the
> null ptr deref is in change()?
> The null ptr deref (and the uaf if you add a delay) is in dequeue
> (ets_qdisc_dequeue()) i.e not in change.
I understand this - it happens to DRR classes that are beyond 'nbands'
after the call to ets_qdisc_change(). Since those queues can have some packets
stored, in ets_qdisc_dequeue() you might have observed:
480 cl = list_first_entry(&q->active, struct ets_class, alist);
481 skb = cl->qdisc->ops->peek(cl->qdisc);
with a "problematic" value in cl->qdisc. That's why I suggest to add
[1] Fixes: de6d25924c2a ("net/sched: sch_ets: don't peek at classes beyond 'nbands'")
in the metadata.
> If that makes sense, what would be a more appropriate Fixes?
the line you are changing in the patch above was added with:
c062f2a0b04d ("net/sched: sch_ets: don't remove idle classes from the round-robin list")
and the commit message said:
<< we can remove 'q->classes[i].alist' only if DRR class 'i' was part of the active
list. In the ETS scheduler DRR classes belong to that list only if the queue length
is greater than zero >>
this assumption on the queue length is no more valid, maybe it has never been valid :),
hence my suggestion to add also
[2] Fixes: c062f2a0b04d ("net/sched: sch_ets: don't remove idle classes from the round-robin list")
> BTW, is that q->classes[i].qdisc = NULL even needed after this?
> It was not clear whether it guards against something else that was not
> obvious from inspection.
That NULL assignment is done in ets_qdisc_change() since the beginning: for classes
beyond 'nbands' we had
for (i = q->nbands; i < oldbands; i++) {
qdisc_put(q->classes[i].qdisc);
memset(&q->classes[i], 0, sizeof(q->classes[i]));
in the very first implementation of sch_ets that memset() was wrongly overwriting 'alist'.
The NULL assignment is not strictly necessary, but any value of 'q->classes[i].qdisc'
is either a UAF or a NULL dereference when 'i' is greater or equal to 'q->nbands'.
I see that ETS sometimes assigns the noop qdisc there: maybe we can assign that to
'q->classes[i].qdisc' when 'i' is greater or equal to 'q->nbands', instead of NULL ? so
the value of 'q->classes[i].qdisc' is a valid pointer all the times? In case it makes some
sense, that would be a follow-up patch targeting net-next that I can test and send. Any
feedback appreciated!
thanks,
--
davide
Powered by blists - more mailing lists