Skip to content

Commit e877f8f

Browse files
Dan Carpentergregkh
authored andcommitted
net: sched: Fix use after free in red_enqueue()
[ Upstream commit 8bdc2ac ] 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]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 81c3e3e commit e877f8f

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
@@ -63,6 +63,7 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,
6363
{
6464
struct red_sched_data *q = qdisc_priv(sch);
6565
struct Qdisc *child = q->qdisc;
66+
unsigned int len;
6667
int ret;
6768

6869
q->vars.qavg = red_calc_qavg(&q->parms,
@@ -98,9 +99,10 @@ static int red_enqueue(struct sk_buff *skb, struct Qdisc *sch,
9899
break;
99100
}
100101

102+
len = qdisc_pkt_len(skb);
101103
ret = qdisc_enqueue(skb, child, to_free);
102104
if (likely(ret == NET_XMIT_SUCCESS)) {
103-
qdisc_qstats_backlog_inc(sch, skb);
105+
sch->qstats.backlog += len;
104106
sch->q.qlen++;
105107
} else if (net_xmit_drop_count(ret)) {
106108
q->stats.pdrop++;

0 commit comments

Comments
 (0)