netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: sched: prevent a use after free
@ 2020-01-31  6:56 Dan Carpenter
  2020-02-01 19:38 ` Cong Wang
  0 siblings, 1 reply; 8+ messages in thread
From: Dan Carpenter @ 2020-01-31  6:56 UTC (permalink / raw)
  To: Jamal Hadi Salim
  Cc: Cong Wang, Jiri Pirko, David S. Miller, Jakub Kicinski,
	Mohit Bhasi, Mohit P. Tahiliani, V. Saicharan,
	Gautam Ramakrishnan, netdev, kernel-janitors

The code calls kfree_skb(skb); and then re-uses "skb" on the next line.
Let's re-order these lines to solve the problem.

Fixes: ec97ecf1ebe4 ("net: sched: add Flow Queue PIE packet scheduler")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 net/sched/sch_fq_pie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/sched/sch_fq_pie.c b/net/sched/sch_fq_pie.c
index bbd0dea6b6b9..78472e0773e9 100644
--- a/net/sched/sch_fq_pie.c
+++ b/net/sched/sch_fq_pie.c
@@ -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;
+		kfree_skb(skb);
 	}
 	qdisc_tree_reduce_backlog(sch, num_dropped, len_dropped);
 
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-02-06 13:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-31  6:56 [PATCH net] net: sched: prevent a use after free Dan Carpenter
2020-02-01 19:38 ` Cong Wang
2020-02-03  8:38   ` Dan Carpenter
2020-02-03 19:58     ` Cong Wang
2020-02-03 20:33       ` Cong Wang
2020-02-05 11:53         ` [PATCH v2 " Dan Carpenter
2020-02-05 18:03           ` Cong Wang
2020-02-06 13:01           ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).