aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCong Wang <xiyou.wangcong@gmail.com>2017-11-01 13:23:49 -0400
committerDavid S. Miller <davem@davemloft.net>2017-11-02 21:30:38 -0400
commita159d3c4b8291998c018f0dbddd4678315264a1e (patch)
treebbc6afb3b37bb06103e40b963eca79685bc49768
parent74784da82ff74379d0583a3ffe42835888705ac7 (diff)
net_sched: acquire RTNL in tc_action_net_exit()
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>
-rw-r--r--include/net/act_api.h2
-rw-r--r--net/sched/act_api.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/include/net/act_api.h b/include/net/act_api.h
index b944e0eb93be..5072446d5f06 100644
--- a/include/net/act_api.h
+++ b/include/net/act_api.h
@@ -122,7 +122,9 @@ void tcf_idrinfo_destroy(const struct tc_action_ops *ops,
122 122
123static inline void tc_action_net_exit(struct tc_action_net *tn) 123static inline void tc_action_net_exit(struct tc_action_net *tn)
124{ 124{
125 rtnl_lock();
125 tcf_idrinfo_destroy(tn->ops, tn->idrinfo); 126 tcf_idrinfo_destroy(tn->ops, tn->idrinfo);
127 rtnl_unlock();
126 kfree(tn->idrinfo); 128 kfree(tn->idrinfo);
127} 129}
128 130
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index da6fa82c98a8..8f2c63514956 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -86,6 +86,8 @@ int __tcf_idr_release(struct tc_action *p, bool bind, bool strict)
86{ 86{
87 int ret = 0; 87 int ret = 0;
88 88
89 ASSERT_RTNL();
90
89 if (p) { 91 if (p) {
90 if (bind) 92 if (bind)
91 p->tcfa_bindcnt--; 93 p->tcfa_bindcnt--;