Skip to content

Commit 8bdc2ac

Browse files
Dan Carpenterdavem330
Dan Carpenter
authored andcommitted
net: sched: Fix use after free in red_enqueue()
We can't use "skb" again after passing it to qdisc_enqueue(). This is basically identical to commit 2f09707 ("sch_sfb: Also store skb len before calling child enqueue"). Fixes: d7f4f33 ("sch_red: update backlog as well") Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 06a4df5 commit 8bdc2ac

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

net/sched/sch_red.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,
7272
{
7373
struct red_sched_data *q = qdisc_priv(sch);
7474
struct Qdisc *child = q->qdisc;
75+
unsigned int len;
7576
int ret;
7677

7778
q->vars.qavg = red_calc_qavg(&q->parms,
@@ -126,9 +127,10 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,
126127
break;
127128
}
128129

130+
len = qdisc_pkt_len(skb);
129131
ret = qdisc_enqueue(skb, child, to_free);
130132
if (likely(ret == NET_XMIT_SUCCESS)) {
131-
qdisc_qstats_backlog_inc(sch, skb);
133+
sch->qstats.backlog += len;
132134
sch->q.qlen++;
133135
} else if (net_xmit_drop_count(ret)) {
134136
q->stats.pdrop++;

0 commit comments

Comments
 (0)