Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1060633ybk; Wed, 20 May 2020 20:24:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzu0AJs1E9lKdN4MqMK3y0Mdge+1kU9FLMiPyhauVfxS0FH5DLFOouVrNieWzgSGf58H+T X-Received: by 2002:a17:906:9157:: with SMTP id y23mr1908950ejw.0.1590031454232; Wed, 20 May 2020 20:24:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590031454; cv=none; d=google.com; s=arc-20160816; b=IKCHWeZnwMPC1oNKJTIHVRVp0RCDar7VlGZMnyemJ1g4VyE02wOvVtdJMI1oa87dHh FpjB59DggbvF94+9ca/vpiYLYHjF7cCaJpndpGwDnFNBYIfubWtmjX3YZXPhXlravnr0 6CV6bBo8scUGj0lU+IJnHehcSvLUUBp8eLFbc7hJaGqjr3oh57eLq5Yt91rvSykw7HSo FYfkORAO9IwGCh/PTi2xHolz7RQkQvcRI9wMayU0ohA0Wjc8nniksCPepmj8AIm1465f QPhFvUvG3el64PjNYQjwMchkgiYRjMyWEE5NcC2y2H0+EnNgu7ppgCMUVT+IBreMXQGK a2Gg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:cc:subject:date:to :from; bh=uAY+jFQtMTQOeU/ZZ//R7BHerFxr8M6gG5Y5k9E2xa0=; b=YtpdAJXrq6TKyG08BjxNZTppYTsV7EjNSETElBc119HxG07ZYI6VMoBK/YIN2uzfi7 pYmhbJJyW6Jfl9EXEnv6dNgTFkpyyUEsn2oawG8llRr8bkFeIlr6iBTzPU3XmK/28I+9 0OPRnUxwWrlqOpH2wNwz/4P4B2MYd3bw7/Ly8rJvMi3nUUjzXoTu7mye1Si39KPub/oF KhF0aoAtkisfkbJXqNyQvkk3p1mNXp55F9lPwtuEmBYwLKlmVNnNOo5bb7N3EPY8I67S GlxXE9zIOF8pJXbHIi/s1r0DqDEBDhTX5DSwFapz2lcuCAzvQyYQTdzYInQjZ1xpdB3S S3Bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b10si2830270ejz.446.2020.05.20.20.23.51; Wed, 20 May 2020 20:24:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728072AbgEUDXN (ORCPT + 99 others); Wed, 20 May 2020 23:23:13 -0400 Received: from mx2.suse.de ([195.135.220.15]:59126 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727825AbgEUDXN (ORCPT ); Wed, 20 May 2020 23:23:13 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 6DD5FB132; Thu, 21 May 2020 03:23:14 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Chuck Lever , kircherlike@outlook.com, Stephen Hemminger Date: Thu, 21 May 2020 13:21:41 +1000 Subject: [PATCH 3/3] sunrpc: clean up properly in gss_mech_unregister() Cc: linux-nfs@vger.kernel.org Message-ID: <159003130171.24897.14813111815409180711.stgit@noble> In-Reply-To: <159003086409.24897.4659128962844846611.stgit@noble> References: <159003086409.24897.4659128962844846611.stgit@noble> User-Agent: StGit/0.21 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org gss_mech_register() calls svcauth_gss_register_pseudoflavor() for each flavour, but gss_mech_unregister() does not call auth_domain_put(). This is unbalanced and makes it impossible to reload the module. Change svcauth_gss_register_pseudoflavor() to return the registered auth_domain, and save it for later release. Link: https://bugzilla.kernel.org/show_bug.cgi?id=206651 Cc: stable@vger.kernel.org Signed-off-by: NeilBrown --- include/linux/sunrpc/gss_api.h | 1 + include/linux/sunrpc/svcauth_gss.h | 3 ++- net/sunrpc/auth_gss/gss_mech_switch.c | 12 +++++++++--- net/sunrpc/auth_gss/svcauth_gss.c | 12 ++++++------ 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h index bc07e51f20d1..bf4ac8a0268c 100644 --- a/include/linux/sunrpc/gss_api.h +++ b/include/linux/sunrpc/gss_api.h @@ -84,6 +84,7 @@ struct pf_desc { u32 service; char *name; char *auth_domain_name; + struct auth_domain *domain; bool datatouch; }; diff --git a/include/linux/sunrpc/svcauth_gss.h b/include/linux/sunrpc/svcauth_gss.h index ca39a388dc22..8983628b10ff 100644 --- a/include/linux/sunrpc/svcauth_gss.h +++ b/include/linux/sunrpc/svcauth_gss.h @@ -20,7 +20,8 @@ int gss_svc_init(void); void gss_svc_shutdown(void); int gss_svc_init_net(struct net *net); void gss_svc_shutdown_net(struct net *net); -int svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name); +struct auth_domain *svcauth_gss_register_pseudoflavor(u32 pseudoflavor, + char * name); u32 svcauth_gss_flavor(struct auth_domain *dom); #endif /* _LINUX_SUNRPC_SVCAUTH_GSS_H */ diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c index 69316ab1b9fa..fae632da1058 100644 --- a/net/sunrpc/auth_gss/gss_mech_switch.c +++ b/net/sunrpc/auth_gss/gss_mech_switch.c @@ -37,6 +37,8 @@ gss_mech_free(struct gss_api_mech *gm) for (i = 0; i < gm->gm_pf_num; i++) { pf = &gm->gm_pfs[i]; + if (pf->domain) + auth_domain_put(pf->domain); kfree(pf->auth_domain_name); pf->auth_domain_name = NULL; } @@ -59,6 +61,7 @@ make_auth_domain_name(char *name) static int gss_mech_svc_setup(struct gss_api_mech *gm) { + struct auth_domain *dom; struct pf_desc *pf; int i, status; @@ -68,10 +71,13 @@ gss_mech_svc_setup(struct gss_api_mech *gm) status = -ENOMEM; if (pf->auth_domain_name == NULL) goto out; - status = svcauth_gss_register_pseudoflavor(pf->pseudoflavor, - pf->auth_domain_name); - if (status) + dom = svcauth_gss_register_pseudoflavor( + pf->pseudoflavor, pf->auth_domain_name); + if (IS_ERR(dom)) { + status = PTR_ERR(dom); goto out; + } + pf->domain = dom; } return 0; out: diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c index 4aaaad794edb..4441920c3d04 100644 --- a/net/sunrpc/auth_gss/svcauth_gss.c +++ b/net/sunrpc/auth_gss/svcauth_gss.c @@ -809,7 +809,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom) EXPORT_SYMBOL_GPL(svcauth_gss_flavor); -int +struct auth_domain * svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name) { struct gss_domain *new; @@ -833,17 +833,17 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name) name); stat = -EALREADY; auth_domain_put(test); - kfree(new->h.name); - goto out_free_dom; + goto out_free_name; } - return 0; + return test; +out_free_name: + kfree(new->h.name); out_free_dom: kfree(new); out: - return stat; + return ERR_PTR(stat); } - EXPORT_SYMBOL_GPL(svcauth_gss_register_pseudoflavor); static inline int