Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1902060ybk; Thu, 21 May 2020 19:04:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzG9AHrmQ9CpgRwTZS3GiAip/M4kK+Q2jsevn6LkYkoBAMNCvZb6RTwiSg+o8ki5TnuS4HV X-Received: by 2002:a17:906:82d9:: with SMTP id a25mr6111469ejy.43.1590113056000; Thu, 21 May 2020 19:04:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590113055; cv=none; d=google.com; s=arc-20160816; b=lZkR5okU/5HfPAAezg2G+09wER/w8MIFgYPUnAjW9oIMr49VstRY1JiQLtQ5xL1cj5 fqKL2gWsYyvNCSST6/VuAVhpMtNnDEPKFkXhtAIaB9zYkkjN2oy8mAqCUq5WB9gA/YVw 62xu32itcS0URnEAFPNUMrph/m5MGiuHN8D9H4RtdFncgKYJ62HPzdX8bvaQygjw8JbX L92Y8Ay1D9j1f6/zMFOvR+eJBf61alhCfF+M1xkMQdZy53Ox2fPMlbNj8nBxl06FEukP 0bC9AR5CQ+y/UTiy7DGrhjn9Vio1I+MuEaC05KVBQkxqiBNVDtvOrcvo4E2sdW7Ro2i7 iBVg== 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=VNISzTjxvR2K6cPOH5uWmwzrtaoLSM82O6UEoe+dprA=; b=A5K7RSf1pMF/9V5sMo/LunEPNW+KQyw7uK1ah7waPwoFu4VVZp7MC0So8P068f9ggV DqSeX+ZsAyDdv/rXlsvLMn+ftcj+Lh4NNE48rZvl+OjHJIAsot1GbXFhKBqAzlMdjdb9 aEYdfwnW8fctAJOw4z4a1/CZcie0wXmudyxqzJAqImAdl4r+aenTWuiIAYZ1Nh891V1F ZN4XFUgKF4bvHdxaBYlda2VYW5/ExuwWyOzOVDSU1Euoglj6CBDpMA9G6gzZEcvtSacI h4F5KlEyaTQVjNoLKCMdg7FMPCVlVY50bF0+AF03OjQw6iOclCE7U+neoOsiFcuqs6Sk Du2g== 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 i29si4032219edj.93.2020.05.21.19.03.52; Thu, 21 May 2020 19:04:15 -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 S1727069AbgEVCDt (ORCPT + 99 others); Thu, 21 May 2020 22:03:49 -0400 Received: from mx2.suse.de ([195.135.220.15]:47432 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgEVCDt (ORCPT ); Thu, 21 May 2020 22:03:49 -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 7FEF8AD09; Fri, 22 May 2020 02:03:50 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Chuck Lever , kircherlike@outlook.com, Stephen Hemminger Date: Fri, 22 May 2020 12:01:33 +1000 Subject: [PATCH 3/3] sunrpc: clean up properly in gss_mech_unregister() Cc: linux-nfs@vger.kernel.org Message-ID: <159011289300.29107.18158467549734203675.stgit@noble> In-Reply-To: <159011265914.29107.13764997801950546826.stgit@noble> References: <159011265914.29107.13764997801950546826.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. Cc: stable@vger.kernel.org (v2.6.12+) Link: https://bugzilla.kernel.org/show_bug.cgi?id=206651 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 49bb346a6215..46027d0c903f 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; @@ -832,17 +832,17 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name) name); stat = -EADDRINUSE; 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