[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAKa-r6skpM6YDoU5i-d34v+9UwKfVe-P1cOFRqynB5h7jJCogg@mail.gmail.com>
Date: Tue, 23 Nov 2021 14:03:08 +0100
From: Davide Caratti <dcaratti@...hat.com>
To: Jamal Hadi Salim <jhs@...atatu.com>,
Cong Wang <xiyou.wangcong@...il.com>,
Jiri Pirko <jiri@...nulli.us>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Petr Machata <petrm@...lanox.com>
Cc: Linux Kernel Network Developers <netdev@...r.kernel.org>,
Hangbin Liu <liuhangbin@...il.com>
Subject: Re: [PATCH net] net/sched: sch_ets: don't peek at classes beyond 'nbands'
hello,
On Tue, Nov 23, 2021 at 12:29 PM Davide Caratti <dcaratti@...hat.com> wrote:
>
> when the number of DRR classes decreases, the round-robin active list can
> contain elements that have already been freed in ets_qdisc_change(). As a
> consequence, it's possible to see a NULL dereference crash,
[...]
> diff --git a/net/sched/sch_ets.c b/net/sched/sch_ets.c
> index 0eae9ff5edf6..3b4ae56ebb19 100644
> --- a/net/sched/sch_ets.c
> +++ b/net/sched/sch_ets.c
> @@ -480,6 +480,10 @@ static struct sk_buff *ets_qdisc_dequeue(struct Qdisc *sch)
> goto out;
>
> cl = list_first_entry(&q->active, struct ets_class, alist);
> + if (!cl->qdisc) {
> + list_del(&cl->alist);
> + goto out;
on a second thought, we probably can do better than 'goto out'.
The round-robin list might contain some other entry, so probably it's
better to cxheck if the list is now empty, and if not re-do that
cl = list_first_entry(&q->active,...)
assignment. So, 'dequeue' dequeues the first valid skb in the round
robin even after cleaning up those no-more-valid list entries. I will
send a v2 in the next minutes.
--
davide
Powered by blists - more mailing lists