Skip to content

Commit 7a02ea6

Browse files
Dan Carpenterdavem330
authored andcommitted
net: sched: prevent a use after free
The bug is that we call kfree_skb(skb) and then pass "skb" to qdisc_pkt_len(skb) on the next line, which is a use after free. Also Cong Wang points out that it's better to delay the actual frees until we drop the rtnl lock so we should use rtnl_kfree_skbs() instead of kfree_skb(). Cc: Cong Wang <[email protected]> Fixes: ec97ecf ("net: sched: add Flow Queue PIE packet scheduler") Signed-off-by: Dan Carpenter <[email protected]> Acked-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 86b18aa commit 7a02ea6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/sched/sch_fq_pie.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,9 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,
349349
while (sch->q.qlen > sch->limit) {
350350
struct sk_buff *skb = fq_pie_qdisc_dequeue(sch);
351351

352-
kfree_skb(skb);
353352
len_dropped += qdisc_pkt_len(skb);
354353
num_dropped += 1;
354+
rtnl_kfree_skbs(skb, skb);
355355
}
356356
qdisc_tree_reduce_backlog(sch, num_dropped, len_dropped);
357357

0 commit comments

Comments
 (0)