From patchwork Fri Jul 28 20:21:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Adamson X-Patchwork-Id: 9869391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A47B6603F9 for ; Fri, 28 Jul 2017 20:22:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AF5E28901 for ; Fri, 28 Jul 2017 20:22:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9003D28907; Fri, 28 Jul 2017 20:22:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 33A8828905 for ; Fri, 28 Jul 2017 20:22:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752633AbdG1UWa (ORCPT ); Fri, 28 Jul 2017 16:22:30 -0400 Received: from mx142.netapp.com ([216.240.21.19]:52446 "EHLO mx142.netapp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752647AbdG1UW3 (ORCPT ); Fri, 28 Jul 2017 16:22:29 -0400 X-IronPort-AV: E=Sophos;i="5.40,427,1496127600"; d="scan'208";a="203129302" Received: from vmwexchts01-prd.hq.netapp.com ([10.122.105.12]) by mx142-out.netapp.com with ESMTP; 28 Jul 2017 13:00:25 -0700 Received: from smtp1.corp.netapp.com (10.57.156.124) by VMWEXCHTS01-PRD.hq.netapp.com (10.122.105.12) with Microsoft SMTP Server id 15.0.1210.3; Fri, 28 Jul 2017 13:22:08 -0700 Received: from localhost.localdomain.localdomain (dros-16.vpn.netapp.com [10.55.79.21]) by smtp1.corp.netapp.com (8.13.1/8.13.1/NTAP-1.6) with ESMTP id v6SKM1lg007987; Fri, 28 Jul 2017 13:22:08 -0700 (PDT) From: To: CC: , , , , Andy Adamson Subject: [PATCH Version 6 07/12] SUNRPC-AUTH_GSS gss3_free_assertions Date: Fri, 28 Jul 2017 16:21:53 -0400 Message-ID: <1501273318-14200-8-git-send-email-andros@netapp.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1501273318-14200-1-git-send-email-andros@netapp.com> References: <1501273318-14200-1-git-send-email-andros@netapp.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andy Adamson Upon GSS context destruction, Free all associated GSS3 child assertions Signed-off-by: Andy Adamson --- include/linux/sunrpc/gss_api.h | 1 + net/sunrpc/auth_gss/auth_gss.c | 51 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h index 7e5da3a..4e02204 100644 --- a/include/linux/sunrpc/gss_api.h +++ b/include/linux/sunrpc/gss_api.h @@ -19,6 +19,7 @@ struct gss3_assert { struct list_head gss3_list; /* per context list of assertions */ + struct rcu_head gss3_rcu; struct xdr_netobj gss3_handle; /* child handle */ u32 gss3_num; /* always one for now */ struct gss3_assertion_u *gss3_assertion; diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 1014521..0df1938 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -60,6 +60,7 @@ static struct gss3_assert *gss3_use_child_handle(struct rpc_cred *cred, struct gss_cl_ctx *ctx); static struct gss3_assert *gss3_match_label(struct gss3_assert_list *in); +static void gss3_free_assertions(struct gss3_assert_list *in); static const struct rpc_authops authgss_ops; @@ -130,8 +131,10 @@ struct gss_auth { static inline void gss_put_ctx(struct gss_cl_ctx *ctx) { - if (atomic_dec_and_test(&ctx->count)) + if (atomic_dec_and_test(&ctx->count)) { + gss3_free_assertions(&ctx->gc_alist); gss_free_ctx(ctx); + } } /* gss3_label_enabled: @@ -1672,6 +1675,52 @@ static void gss3_free_label(struct gss3_label *gl) kfree(gl->la_label.data); } +static void +gss3_free_assertion(struct gss3_assert *freeme) +{ + /* allocated in gss3_dec_create */ + kfree(freeme->gss3_handle.data); + + /* gss3_num is always one for now */ + switch (freeme->gss3_assertion->au_type) { + case GSS3_LABEL: + gss3_free_label(&freeme->gss3_assertion->u.au_label); + break; + case GSS3_PRIVS: + default: + pr_warn("RPC %s Can't free unsupported au_type %d\n", + __func__, freeme->gss3_assertion->au_type); + return; + } + kfree(freeme); +} + +static void +gss3_free_assert_callback(struct rcu_head *head) +{ + struct gss3_assert *g3a = container_of(head, struct gss3_assert, + gss3_rcu); + gss3_free_assertion(g3a); +} + +static void +gss3_free_assert(struct gss3_assert *ap) +{ + call_rcu(&ap->gss3_rcu, gss3_free_assert_callback); +} + +static void gss3_free_assertions(struct gss3_assert_list *in) +{ + struct gss3_assert *found; + + list_for_each_entry_rcu(found, &in->assert_list, gss3_list) { + spin_lock(&in->assert_lock); + list_del_rcu(&found->gss3_list); + spin_unlock(&in->assert_lock); + gss3_free_assert(found); + } +} + static struct gss3_assert * gss3_match_label(struct gss3_assert_list *in) {