[RHEL7,COMMIT] net: Move mutex_unlock() in cleanup_net() up

Submitted by Konstantin Khorenko on May 27, 2020, 6:34 p.m.


Message ID 202005271834.04RIYwZm015141@finist-ce7.sw.ru
State New
Series "Parallel per-net init/exit"
Headers show

Commit Message

Konstantin Khorenko May 27, 2020, 6:34 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.8.2.vz7.161.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.8.2.vz7.161.3
commit 56347e49285000aedd3c610eaefafb6cfaf2bf5c
Author: Kirill Tkhai <ktkhai@virtuozzo.com>
Date:   Wed May 27 21:34:58 2020 +0300

    net: Move mutex_unlock() in cleanup_net() up
    ms commit bcab1ddd9b2b
    net_sem protects from pernet_list changing, while
    ops_free_list() makes simple kfree(), and it can't
    race with other pernet_operations callbacks.
    So we may release net_mutex earlier then it was.
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    Acked-by: Andrei Vagin <avagin@virtuozzo.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Patchset description:
    Parallel per-net init/exit
 net/core/net_namespace.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index f63e32495e493..9827efc52a2e6 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -529,11 +529,12 @@  static void cleanup_net(struct work_struct *work)
 	list_for_each_entry_reverse(ops, &pernet_list, list)
 		ops_exit_list(ops, &net_exit_list);
+	mutex_unlock(&net_mutex);
 	/* Free the net generic variables */
 	list_for_each_entry_reverse(ops, &pernet_list, list)
 		ops_free_list(ops, &net_exit_list);
-	mutex_unlock(&net_mutex);
 	list_for_each_entry(net, &net_kill_list, cleanup_list) {