diff mbox series

[2/3] sunrpc: svcauth_gss_register_pseudoflavor must reject duplicate registrations.

Message ID 159003130169.24897.13093682450013271796.stgit@noble (mailing list archive)
State New, archived
Headers show
Series SUNRPC/svc: fix gss flavour registration problems. | expand

Commit Message

NeilBrown May 21, 2020, 3:21 a.m. UTC
There is no valid case for supporting duplicate pseudoflavor
registrations.
Currently the silent acceptance of such registrations is hiding a bug.
The rpcsec_gss_krb5 module registers 2 flavours but does not unregister
them, so if you load, unload, reload the module, it will happily
continue to use the old registration which now has pointers to the
memory were the module was originally loaded.  This could lead to
unexpected results.

So disallow duplicate registrations.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=206651
Cc: stable@vger.kernel.org
Signed-off-by: NeilBrown <neilb@suse.de>
---
 net/sunrpc/auth_gss/svcauth_gss.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
index 50d93c49ef1a..4aaaad794edb 100644
--- a/net/sunrpc/auth_gss/svcauth_gss.c
+++ b/net/sunrpc/auth_gss/svcauth_gss.c
@@ -826,9 +826,12 @@  svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
 	new->h.flavour = &svcauthops_gss;
 	new->pseudoflavor = pseudoflavor;
 
-	stat = 0;
 	test = auth_domain_lookup(name, &new->h);
 	if (test != &new->h) { /* Duplicate registration */
+		printk(KERN_WARNING
+		       "SUNRPC:svcauth_gss: duplicate pseudo flavour registration of %s\n",
+		       name);
+		stat = -EALREADY;
 		auth_domain_put(test);
 		kfree(new->h.name);
 		goto out_free_dom;