Skip to content

Commit 343723d

Browse files
jpirkodavem330
authored andcommitted
net: sched: fix clsact init error path
Since in qdisc_create, the destroy op is called when init fails, we don't do cleanup in init and leave it up to destroy. This fixes use-after-free when trying to put already freed block. Fixes: 6e40cf2 ("net: sched: use extended variants of block_get/put in ingress and clsact qdiscs") Signed-off-by: Jiri Pirko <[email protected]> Acked-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c05fad5 commit 343723d

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

net/sched/cls_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
351351
{
352352
struct tcf_chain *chain;
353353

354+
if (!block)
355+
return;
354356
/* Hold a refcnt for all chains, except 0, so that they don't disappear
355357
* while we are iterating.
356358
*/
@@ -377,8 +379,6 @@ void tcf_block_put(struct tcf_block *block)
377379
{
378380
struct tcf_block_ext_info ei = {0, };
379381

380-
if (!block)
381-
return;
382382
tcf_block_put_ext(block, block->q, &ei);
383383
}
384384

net/sched/sch_ingress.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,18 +190,14 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt)
190190

191191
err = tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info);
192192
if (err)
193-
goto err_egress_block_get;
193+
return err;
194194

195195
net_inc_ingress_queue();
196196
net_inc_egress_queue();
197197

198198
sch->flags |= TCQ_F_CPUSTATS;
199199

200200
return 0;
201-
202-
err_egress_block_get:
203-
tcf_block_put_ext(q->ingress_block, sch, &q->ingress_block_info);
204-
return err;
205201
}
206202

207203
static void clsact_destroy(struct Qdisc *sch)

0 commit comments

Comments
 (0)