]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
cls_matchall: use tcf_exts_get_net() before call_rcu()
authorCong Wang <xiyou.wangcong@gmail.com>
Mon, 6 Nov 2017 21:47:26 +0000 (13:47 -0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 9 Nov 2017 01:03:10 +0000 (10:03 +0900)
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>
net/sched/cls_matchall.c

index c33f711b90198ab8b77bd314c289d09cbfe2d170..3684153cd8a9e1dfc680bcabf3c13e4fba2f507e 100644 (file)
@@ -44,13 +44,19 @@ static int mall_init(struct tcf_proto *tp)
        return 0;
 }
 
+static void __mall_destroy(struct cls_mall_head *head)
+{
+       tcf_exts_destroy(&head->exts);
+       tcf_exts_put_net(&head->exts);
+       kfree(head);
+}
+
 static void mall_destroy_work(struct work_struct *work)
 {
        struct cls_mall_head *head = container_of(work, struct cls_mall_head,
                                                  work);
        rtnl_lock();
-       tcf_exts_destroy(&head->exts);
-       kfree(head);
+       __mall_destroy(head);
        rtnl_unlock();
 }
 
@@ -109,7 +115,10 @@ static void mall_destroy(struct tcf_proto *tp)
        if (tc_should_offload(dev, head->flags))
                mall_destroy_hw_filter(tp, head, (unsigned long) head);
 
-       call_rcu(&head->rcu, mall_destroy_rcu);
+       if (tcf_exts_get_net(&head->exts))
+               call_rcu(&head->rcu, mall_destroy_rcu);
+       else
+               __mall_destroy(head);
 }
 
 static void *mall_get(struct tcf_proto *tp, u32 handle)