Skip to content

Commit

Permalink
sunrpc: check that domain table is empty at module unload.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
neilbrown authored and J. Bruce Fields committed May 28, 2020
1 parent 6670ee2 commit f45db2b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/sunrpc/sunrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
2 changes: 2 additions & 0 deletions net/sunrpc/sunrpc_syms.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
25 changes: 25 additions & 0 deletions net/sunrpc/svcauth.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <trace/events/sunrpc.h>

#include "sunrpc.h"

#define RPCDBG_FACILITY RPCDBG_AUTH


Expand Down Expand Up @@ -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);
}

0 comments on commit f45db2b

Please sign in to comment.