From 51ec8d80c5cb733e18ebe5ae097b388072e8b30f Mon Sep 17 00:00:00 2001 From: Sasha Levin Date: Fri, 31 Jul 2020 21:07:02 -0400 Subject: [PATCH] Fixes for 5.7 Signed-off-by: Sasha Levin --- queue-5.7/series | 1 + ...t-domain-table-is-empty-at-module-un.patch | 95 +++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 queue-5.7/series create mode 100644 queue-5.7/sunrpc-check-that-domain-table-is-empty-at-module-un.patch diff --git a/queue-5.7/series b/queue-5.7/series new file mode 100644 index 00000000000..bb402a3a16c --- /dev/null +++ b/queue-5.7/series @@ -0,0 +1 @@ +sunrpc-check-that-domain-table-is-empty-at-module-un.patch diff --git a/queue-5.7/sunrpc-check-that-domain-table-is-empty-at-module-un.patch b/queue-5.7/sunrpc-check-that-domain-table-is-empty-at-module-un.patch new file mode 100644 index 00000000000..e5eb3517192 --- /dev/null +++ b/queue-5.7/sunrpc-check-that-domain-table-is-empty-at-module-un.patch @@ -0,0 +1,95 @@ +From d2231258e34ed1abffba009a89945d4c6c572616 Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Fri, 22 May 2020 12:01:32 +1000 +Subject: sunrpc: check that domain table is empty at module unload. + +From: NeilBrown + +[ 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 +Signed-off-by: J. Bruce Fields +Signed-off-by: Sasha Levin +--- + net/sunrpc/sunrpc.h | 1 + + net/sunrpc/sunrpc_syms.c | 2 ++ + net/sunrpc/svcauth.c | 25 +++++++++++++++++++++++++ + 3 files changed, 28 insertions(+) + +diff --git a/net/sunrpc/sunrpc.h b/net/sunrpc/sunrpc.h +index 47a756503d11c..f6fe2e6cd65a1 100644 +--- a/net/sunrpc/sunrpc.h ++++ b/net/sunrpc/sunrpc.h +@@ -52,4 +52,5 @@ static inline int sock_is_loopback(struct sock *sk) + + int rpc_clients_notifier_register(void); + void rpc_clients_notifier_unregister(void); ++void auth_domain_cleanup(void); + #endif /* _NET_SUNRPC_SUNRPC_H */ +diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c +index f9edaa9174a43..236fadc4a4399 100644 +--- a/net/sunrpc/sunrpc_syms.c ++++ b/net/sunrpc/sunrpc_syms.c +@@ -23,6 +23,7 @@ + #include + #include + ++#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 +diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c +index 552617e3467bd..998b196b61767 100644 +--- a/net/sunrpc/svcauth.c ++++ b/net/sunrpc/svcauth.c +@@ -21,6 +21,8 @@ + + #include + ++#include "sunrpc.h" ++ + #define RPCDBG_FACILITY RPCDBG_AUTH + + +@@ -205,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); ++} +-- +2.25.1 + -- 2.47.3