Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1902033ybk; Thu, 21 May 2020 19:04:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqPYOzH7/uu9X2mSNRPM80M/gKPjv5j18hLMXouq0rXMWiT8cQMPQA7FrnLoCoDhMINAWN X-Received: by 2002:a17:906:bfe3:: with SMTP id vr3mr675250ejb.341.1590113052471; Thu, 21 May 2020 19:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590113052; cv=none; d=google.com; s=arc-20160816; b=jI5u59go/hZTjXEYtRSMqvtThdJeNWRQp3mmI9hLH+uK83ILCmIjh+WyNTImIOcmD4 r4z0NbVw/KbG1VkI3Z365ZNi0LUkR+WPjKZSaOXByJNIjo4FF3XtxjyLqdBPPKsjzv2z U3A72uBZTX5yvl6bubXlrn4OpJRu3E19RTm+YSOJUJFFrsEcTd+exOZB/z28PpCmBzni 1u08gyH6SAbpKD9VFvF7OVq+cVi+CbHBTujZi50vEzr7sPQVnGj5JerZgmbmIXqUEiw5 6WypwtQSxvdsXWR38tp702Iu5tfjZ99keWeCxAbZGdgvBYHDid3o90GMkOswP8RDXcSo CReg== 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=rWRfyLdsxN+UDjSPb+KzQ/gHvAC6GzZ9IgwC5J/1V3g=; b=vXYVgiBGVNwIjKvg7ghl5kCTQiKoTKoL7UV15Cu7UURmktw/Lk+l/GVYOvg2PB+foj Hxl087szBJUSIK/+p05ZRizqIucbUghYmE85IRUtdSvVqGlOyBe3OxRQRpJom7voG6T+ SztLzkJ539isoPGdM01y+d0+i7ezuZDDO58Rk8UIehCBg2q3Q2S7D2bVbxNo316tVZFR S0oXgRqPWBYL51Nya/ESWaBNmk2DVteUooAfStHMBeNjqOM26+MjA8v+ykyuWYPjruIO PbKli85oEE25YVVdmcORMrJdtuCqcfllnBT6+57S08RsFRZKQURI81k/xpZ5t3IDNcrR jW5w== 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 c26si1478954edj.45.2020.05.21.19.03.40; Thu, 21 May 2020 19:04:12 -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 S1727055AbgEVCDh (ORCPT + 99 others); Thu, 21 May 2020 22:03:37 -0400 Received: from mx2.suse.de ([195.135.220.15]:47098 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726335AbgEVCDh (ORCPT ); Thu, 21 May 2020 22:03:37 -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 EB8BCAD09; Fri, 22 May 2020 02:03:37 +0000 (UTC) From: NeilBrown To: "J. Bruce Fields" , Chuck Lever , kircherlike@outlook.com, Stephen Hemminger Date: Fri, 22 May 2020 12:01:32 +1000 Subject: [PATCH 1/3] sunrpc: check that domain table is empty at module unload. Cc: linux-nfs@vger.kernel.org Message-ID: <159011289291.29107.750750426822869150.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 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 --- net/sunrpc/sunrpc.h | 1 + net/sunrpc/sunrpc_syms.c | 2 ++ net/sunrpc/svcauth.c | 25 +++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/net/sunrpc/sunrpc.h b/net/sunrpc/sunrpc.h index 47a756503d11..f6fe2e6cd65a 100644 --- a/net/sunrpc/sunrpc.h +++ b/net/sunrpc/sunrpc.h @@ -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 */ diff --git a/net/sunrpc/sunrpc_syms.c b/net/sunrpc/sunrpc_syms.c index f9edaa9174a4..236fadc4a439 100644 --- a/net/sunrpc/sunrpc_syms.c +++ b/net/sunrpc/sunrpc_syms.c @@ -23,6 +23,7 @@ #include #include +#include "sunrpc.h" #include "netns.h" unsigned int sunrpc_net_id; @@ -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 diff --git a/net/sunrpc/svcauth.c b/net/sunrpc/svcauth.c index 552617e3467b..998b196b6176 100644 --- a/net/sunrpc/svcauth.c +++ b/net/sunrpc/svcauth.c @@ -21,6 +21,8 @@ #include +#include "sunrpc.h" + #define RPCDBG_FACILITY RPCDBG_AUTH @@ -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); +}