]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
sunrpc: check that domain table is empty at module unload.
authorSasha Levin <sashal@kernel.org>
Thu, 30 Jul 2020 22:55:53 +0000 (18:55 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 5 Aug 2020 07:59:41 +0000 (09:59 +0200)
[ Upstream commit f45db2b909c7e76f35850e78f017221f30282b8e ]

The domain table should be empty at module unload.  If it isn't there is
a bug somewhere.  So check and report.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=206651
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sunrpc/sunrpc.h
net/sunrpc/sunrpc_syms.c
net/sunrpc/svcauth.c

index c9bacb3c930fa7feeb4fdb110cdfc8e3ee0c177a..82035fa65b8f9d8c701aec70f0af5533ce9dff55 100644 (file)
@@ -56,4 +56,5 @@ int svc_send_common(struct socket *sock, struct xdr_buf *xdr,
 
 int rpc_clients_notifier_register(void);
 void rpc_clients_notifier_unregister(void);
+void auth_domain_cleanup(void);
 #endif /* _NET_SUNRPC_SUNRPC_H */
index f9edaa9174a439ae598a4d9fa501a7c998ac8951..236fadc4a4399a89cf6bfba15cf4ebdcb81976bb 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/sunrpc/rpc_pipe_fs.h>
 #include <linux/sunrpc/xprtsock.h>
 
+#include "sunrpc.h"
 #include "netns.h"
 
 unsigned int sunrpc_net_id;
@@ -131,6 +132,7 @@ cleanup_sunrpc(void)
        unregister_rpc_pipefs();
        rpc_destroy_mempool();
        unregister_pernet_subsys(&sunrpc_net_ops);
+       auth_domain_cleanup();
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
        rpc_unregister_sysctl();
 #endif
index 550b214cb0015611970426fab50cf093b8c370bc..998b196b6176744af28f54f4219b56ffd1713e3e 100644 (file)
 #include <linux/err.h>
 #include <linux/hash.h>
 
+#include <trace/events/sunrpc.h>
+
+#include "sunrpc.h"
+
 #define RPCDBG_FACILITY        RPCDBG_AUTH
 
 
@@ -203,3 +207,26 @@ struct auth_domain *auth_domain_find(char *name)
        return NULL;
 }
 EXPORT_SYMBOL_GPL(auth_domain_find);
+
+/**
+ * auth_domain_cleanup - check that the auth_domain table is empty
+ *
+ * On module unload the auth_domain_table must be empty.  To make it
+ * easier to catch bugs which don't clean up domains properly, we
+ * warn if anything remains in the table at cleanup time.
+ *
+ * Note that we cannot proactively remove the domains at this stage.
+ * The ->release() function might be in a module that has already been
+ * unloaded.
+ */
+
+void auth_domain_cleanup(void)
+{
+       int h;
+       struct auth_domain *hp;
+
+       for (h = 0; h < DN_HASHMAX; h++)
+               hlist_for_each_entry(hp, &auth_domain_table[h], hash)
+                       pr_warn("svc: domain %s still present at module unload.\n",
+                               hp->name);
+}