Skip to content

net: sched: sch_qfq: Fix UAF in qfq_dequeue() #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion net/sched/sch_plug.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static struct Qdisc_ops plug_qdisc_ops __read_mostly = {
.priv_size = sizeof(struct plug_sched_data),
.enqueue = plug_enqueue,
.dequeue = plug_dequeue,
.peek = qdisc_peek_head,
.peek = qdisc_peek_dequeued,
.init = plug_init,
.change = plug_change,
.reset = qdisc_reset_queue,
Expand Down
22 changes: 17 additions & 5 deletions net/sched/sch_qfq.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,10 +973,13 @@ static void qfq_update_eligible(struct qfq_sched *q)
}

/* Dequeue head packet of the head class in the DRR queue of the aggregate. */
static void agg_dequeue(struct qfq_aggregate *agg,
struct qfq_class *cl, unsigned int len)
static struct sk_buff *agg_dequeue(struct qfq_aggregate *agg,
struct qfq_class *cl, unsigned int len)
{
qdisc_dequeue_peeked(cl->qdisc);
struct sk_buff *skb = qdisc_dequeue_peeked(cl->qdisc);

if (!skb)
return NULL;

cl->deficit -= (int) len;

Expand All @@ -986,6 +989,8 @@ static void agg_dequeue(struct qfq_aggregate *agg,
cl->deficit += agg->lmax;
list_move_tail(&cl->alist, &agg->active);
}

return skb;
}

static inline struct sk_buff *qfq_peek_skb(struct qfq_aggregate *agg,
Expand Down Expand Up @@ -1131,11 +1136,18 @@ static struct sk_buff *qfq_dequeue(struct Qdisc *sch)
if (!skb)
return NULL;

qdisc_qstats_backlog_dec(sch, skb);
sch->q.qlen--;

skb = agg_dequeue(in_serv_agg, cl, len);

if (!skb) {
sch->q.qlen++;
return NULL;
}

qdisc_qstats_backlog_dec(sch, skb);
qdisc_bstats_update(sch, skb);

agg_dequeue(in_serv_agg, cl, len);
/* If lmax is lowered, through qfq_change_class, for a class
* owning pending packets with larger size than the new value
* of lmax, then the following condition may hold.
Expand Down
Loading