Skip to content

Commit b1b5b04

Browse files
congwangdavem330
authored andcommitted
net_sched: use tcf_queue_work() in cgroup filter
Defer the tcf_exts_destroy() in RCU callback to tc filter workqueue and get RTNL lock. Reported-by: Chris Mi <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Jiri Pirko <[email protected]> Cc: John Fastabend <[email protected]> Cc: Jamal Hadi Salim <[email protected]> Cc: "Paul E. McKenney" <[email protected]> Signed-off-by: Cong Wang <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent e910af6 commit b1b5b04

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

net/sched/cls_cgroup.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ struct cls_cgroup_head {
2323
struct tcf_exts exts;
2424
struct tcf_ematch_tree ematches;
2525
struct tcf_proto *tp;
26-
struct rcu_head rcu;
26+
union {
27+
struct work_struct work;
28+
struct rcu_head rcu;
29+
};
2730
};
2831

2932
static int cls_cgroup_classify(struct sk_buff *skb, const struct tcf_proto *tp,
@@ -57,15 +60,26 @@ static const struct nla_policy cgroup_policy[TCA_CGROUP_MAX + 1] = {
5760
[TCA_CGROUP_EMATCHES] = { .type = NLA_NESTED },
5861
};
5962

63+
static void cls_cgroup_destroy_work(struct work_struct *work)
64+
{
65+
struct cls_cgroup_head *head = container_of(work,
66+
struct cls_cgroup_head,
67+
work);
68+
rtnl_lock();
69+
tcf_exts_destroy(&head->exts);
70+
tcf_em_tree_destroy(&head->ematches);
71+
kfree(head);
72+
rtnl_unlock();
73+
}
74+
6075
static void cls_cgroup_destroy_rcu(struct rcu_head *root)
6176
{
6277
struct cls_cgroup_head *head = container_of(root,
6378
struct cls_cgroup_head,
6479
rcu);
6580

66-
tcf_exts_destroy(&head->exts);
67-
tcf_em_tree_destroy(&head->ematches);
68-
kfree(head);
81+
INIT_WORK(&head->work, cls_cgroup_destroy_work);
82+
tcf_queue_work(&head->work);
6983
}
7084

7185
static int cls_cgroup_change(struct net *net, struct sk_buff *in_skb,

0 commit comments

Comments
 (0)