diff options
| author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2015-04-03 06:02:36 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-04-03 12:36:31 -0400 |
| commit | 6d458f5b4ece8542a5c2281e40008823fec91814 (patch) | |
| tree | 6e9501d4f615b8ab846b8fd84bb448e65ea5ae42 | |
| parent | 7ba0c47c34a1ea5bc7a24ca67309996cce0569b5 (diff) | |
Revert "netns: don't clear nsid too early on removal"
This reverts
commit 4217291e592d ("netns: don't clear nsid too early on removal").
This is not the right fix, it introduces races.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/core/net_namespace.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index 5221f975a4cc..cb5290b8c428 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c | |||
| @@ -349,7 +349,7 @@ static LIST_HEAD(cleanup_list); /* Must hold cleanup_list_lock to touch */ | |||
| 349 | static void cleanup_net(struct work_struct *work) | 349 | static void cleanup_net(struct work_struct *work) |
| 350 | { | 350 | { |
| 351 | const struct pernet_operations *ops; | 351 | const struct pernet_operations *ops; |
| 352 | struct net *net, *tmp, *peer; | 352 | struct net *net, *tmp; |
| 353 | struct list_head net_kill_list; | 353 | struct list_head net_kill_list; |
| 354 | LIST_HEAD(net_exit_list); | 354 | LIST_HEAD(net_exit_list); |
| 355 | 355 | ||
| @@ -365,6 +365,14 @@ static void cleanup_net(struct work_struct *work) | |||
| 365 | list_for_each_entry(net, &net_kill_list, cleanup_list) { | 365 | list_for_each_entry(net, &net_kill_list, cleanup_list) { |
| 366 | list_del_rcu(&net->list); | 366 | list_del_rcu(&net->list); |
| 367 | list_add_tail(&net->exit_list, &net_exit_list); | 367 | list_add_tail(&net->exit_list, &net_exit_list); |
| 368 | for_each_net(tmp) { | ||
| 369 | int id = __peernet2id(tmp, net, false); | ||
| 370 | |||
| 371 | if (id >= 0) | ||
| 372 | idr_remove(&tmp->netns_ids, id); | ||
| 373 | } | ||
| 374 | idr_destroy(&net->netns_ids); | ||
| 375 | |||
| 368 | } | 376 | } |
| 369 | rtnl_unlock(); | 377 | rtnl_unlock(); |
| 370 | 378 | ||
| @@ -390,26 +398,12 @@ static void cleanup_net(struct work_struct *work) | |||
| 390 | */ | 398 | */ |
| 391 | rcu_barrier(); | 399 | rcu_barrier(); |
| 392 | 400 | ||
| 393 | rtnl_lock(); | ||
| 394 | /* Finally it is safe to free my network namespace structure */ | 401 | /* Finally it is safe to free my network namespace structure */ |
| 395 | list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) { | 402 | list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) { |
| 396 | /* Unreference net from all peers (no need to loop over | ||
| 397 | * net_exit_list because idr_destroy() will be called for each | ||
| 398 | * element of this list. | ||
| 399 | */ | ||
| 400 | for_each_net(peer) { | ||
| 401 | int id = __peernet2id(peer, net, false); | ||
| 402 | |||
| 403 | if (id >= 0) | ||
| 404 | idr_remove(&peer->netns_ids, id); | ||
| 405 | } | ||
| 406 | idr_destroy(&net->netns_ids); | ||
| 407 | |||
| 408 | list_del_init(&net->exit_list); | 403 | list_del_init(&net->exit_list); |
| 409 | put_user_ns(net->user_ns); | 404 | put_user_ns(net->user_ns); |
| 410 | net_drop_ns(net); | 405 | net_drop_ns(net); |
| 411 | } | 406 | } |
| 412 | rtnl_unlock(); | ||
| 413 | } | 407 | } |
| 414 | static DECLARE_WORK(net_cleanup_work, cleanup_net); | 408 | static DECLARE_WORK(net_cleanup_work, cleanup_net); |
| 415 | 409 | ||
