Skip to content

Commit

Permalink
net: sched: prevent a use after free
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Dan Carpenter authored and davem330 committed Feb 6, 2020
1 parent 86b18aa commit 7a02ea6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/sched/sch_fq_pie.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ static int fq_pie_change(struct Qdisc *sch, struct nlattr *opt,
while (sch->q.qlen > sch->limit) {
struct sk_buff *skb = fq_pie_qdisc_dequeue(sch);

kfree_skb(skb);
len_dropped += qdisc_pkt_len(skb);
num_dropped += 1;
rtnl_kfree_skbs(skb, skb);
}
qdisc_tree_reduce_backlog(sch, num_dropped, len_dropped);

Expand Down

0 comments on commit 7a02ea6

Please sign in to comment.