Skip to content

Commit 57767e7

Browse files
congwangdavem330
authored andcommitted
cls_matchall: use tcf_exts_get_net() before call_rcu()
Hold netns refcnt before call_rcu() and release it after the tcf_exts_destroy() is done. Cc: Lucas Bates <lucasb@mojatatu.com> Cc: Jamal Hadi Salim <jhs@mojatatu.com> Cc: Jiri Pirko <jiri@resnulli.us> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d5f984f commit 57767e7

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

net/sched/cls_matchall.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,19 @@ static int mall_init(struct tcf_proto *tp)
4444
return 0;
4545
}
4646

47+
static void __mall_destroy(struct cls_mall_head *head)
48+
{
49+
tcf_exts_destroy(&head->exts);
50+
tcf_exts_put_net(&head->exts);
51+
kfree(head);
52+
}
53+
4754
static void mall_destroy_work(struct work_struct *work)
4855
{
4956
struct cls_mall_head *head = container_of(work, struct cls_mall_head,
5057
work);
5158
rtnl_lock();
52-
tcf_exts_destroy(&head->exts);
53-
kfree(head);
59+
__mall_destroy(head);
5460
rtnl_unlock();
5561
}
5662

@@ -109,7 +115,10 @@ static void mall_destroy(struct tcf_proto *tp)
109115
if (tc_should_offload(dev, head->flags))
110116
mall_destroy_hw_filter(tp, head, (unsigned long) head);
111117

112-
call_rcu(&head->rcu, mall_destroy_rcu);
118+
if (tcf_exts_get_net(&head->exts))
119+
call_rcu(&head->rcu, mall_destroy_rcu);
120+
else
121+
__mall_destroy(head);
113122
}
114123

115124
static void *mall_get(struct tcf_proto *tp, u32 handle)

0 commit comments

Comments
 (0)