Revert "net: defer final 'struct net' free in netns dismantle"

This reverts commit 3267b254dc which is
commit 0f6ede9fbc747e2553612271bce108f7517e7a45 upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: I4811e911553091a47d11e0b4ece358363809166c
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman
2025-01-04 10:37:23 +00:00
parent e31da5fb5c
commit 747746a3c9
2 changed files with 1 additions and 21 deletions

View File

@@ -81,7 +81,6 @@ struct net {
* or to unregister pernet ops
* (pernet_ops_rwsem write locked).
*/
struct llist_node defer_free_list;
struct llist_node cleanup_list; /* namespaces on death row */
#ifdef CONFIG_KEYS

View File

@@ -435,28 +435,11 @@ out_free:
goto out;
}
static LLIST_HEAD(defer_free_list);
static void net_complete_free(void)
{
struct llist_node *kill_list;
struct net *net, *next;
/* Get the list of namespaces to free from last round. */
kill_list = llist_del_all(&defer_free_list);
llist_for_each_entry_safe(net, next, kill_list, defer_free_list)
kmem_cache_free(net_cachep, net);
}
static void net_free(struct net *net)
{
if (refcount_dec_and_test(&net->passive)) {
kfree(rcu_access_pointer(net->gen));
/* Wait for an extra rcu_barrier() before final free. */
llist_add(&net->defer_free_list, &defer_free_list);
kmem_cache_free(net_cachep, net);
}
}
@@ -631,8 +614,6 @@ static void cleanup_net(struct work_struct *work)
*/
rcu_barrier();
net_complete_free();
/* Finally it is safe to free my network namespace structure */
list_for_each_entry_safe(net, tmp, &net_exit_list, exit_list) {
list_del_init(&net->exit_list);