]> git.itanic.dy.fi Git - linux-stable/commitdiff
net_sched: acquire RTNL in tc_action_net_exit()
authorCong Wang <xiyou.wangcong@gmail.com>
Wed, 1 Nov 2017 17:23:49 +0000 (10:23 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Nov 2017 01:30:38 +0000 (10:30 +0900)
I forgot to acquire RTNL in tc_action_net_exit()
which leads that action ops->cleanup() is not always
called with RTNL. This usually is not a big deal because
this function is called after all netns refcnt are gone,
but given RTNL protects more than just actions, add it
for safety and consistency.

Also add an assertion to catch other potential bugs.

Fixes: ddf97ccdd7cb ("net_sched: add network namespace support for tc actions")
Reported-by: Lucas Bates <lucasb@mojatatu.com>
Tested-by: 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>
include/net/act_api.h
net/sched/act_api.c

index b944e0eb93be367944673939a943b05c3473f2e9..5072446d5f06f0935dc4e506635c4bee317ac4c4 100644 (file)
@@ -122,7 +122,9 @@ void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
 
 static inline void tc_action_net_exit(struct tc_action_net *tn)
 {
+       rtnl_lock();
        tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
+       rtnl_unlock();
        kfree(tn->idrinfo);
 }
 
index da6fa82c98a8b7fb0d4e94cdfcaa0198e6972d90..8f2c635149561e741bda88163df063f8cc70f957 100644 (file)
@@ -86,6 +86,8 @@ int __tcf_idr_release(struct tc_action *p, bool bind, bool strict)
 {
        int ret = 0;
 
+       ASSERT_RTNL();
+
        if (p) {
                if (bind)
                        p->tcfa_bindcnt--;