Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1060371ybk; Wed, 20 May 2020 20:23:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3QGaj3flz1eqKyYz63yUP/fSEBi79uHSF95MjWGYXHJ12zuBj3iRtUgHmGZ5Fx9oUT4YJ X-Received: by 2002:a17:906:2e0e:: with SMTP id n14mr1691139eji.545.1590031421129; Wed, 20 May 2020 20:23:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590031421; cv=none; d=google.com; s=arc-20160816; b=C1l8lotqUj983Kle3xBMBwiXAvq7H+uH4UVG1buoAWXJFuy5XWU8djGtC1QyF3AO4d An/VMFUCCTBIxNub0+LbsHIUilfiOmeP+ft8d89kedmzCQTYABI6W1S+U/F0EAvTMUpz 5ThJfaWULJ+kydJKnvqDa59sWBBSfxSpp7WAFYOZoejL0MxuhVLwxTG+qNcby7PLs2Gu pvhz/4b3TGdnget2UJimSPAHeacmbK6sSZ42E31w4qmU1vOfj8fEHYK5nZZKBSVH7XBe r5KgtpH0ZP49CikMRb0I1lhHE6+7ONyaBXUFH0x3Vumdk8GhcSEoBjAqZBd/xTrWHdyP wVxw== 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=WMJ+o7qoYVHXvhcKHvpmA5cnVjn2EF8E/zIgt8lVBdI=; b=yu2pN9trGoGfiYL21gXsDpT+4wAafjPCqTIKa15fgnZu25nsUGCI+sYV7KOwyh/os6 wlP2pm+LdBepqleIjlYZZzvTtOmuPNUAxEegQrCIUnglcWrR1fMDncNf1z3ZW297bxuV sLC61ZmFsBkqxa0aCrC0maz7S5vyHPLYatVdumPPEe3Jv1/5tkx4myAUntVR3SFs3ftv Awe1pFd1Dl4uZxd+8eeWrlFwgGHOXVsL4KA+hSnOXCVnJUGd37sBNjllaSR4O9RW0Z7l PTZbOUiNR3ifwpXDqiVIxu4Y41qnDs4I8OS/kT0twz+5N34dd16jCW7ImeX2WA8SK0ks kj1w== 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 i19si2909745ejy.14.2020.05.20.20.23.11; Wed, 20 May 2020 20:23:41 -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 S1728048AbgEUDXB (ORCPT + 99 others); Wed, 20 May 2020 23:23:01 -0400 Received: from mx2.suse.de ([195.135.220.15]:58966 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727825AbgEUDXA (ORCPT ); Wed, 20 May 2020 23:23:00 -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 E641CB13E; Thu, 21 May 2020 03:23:01 +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 1/3] sunrpc: check that domain table is empty at module unload. Cc: linux-nfs@vger.kernel.org Message-ID: <159003130168.24897.13206733830315341548.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 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 Cc: stable@vger.kernel.org Signed-off-by: NeilBrown --- net/sunrpc/sunrpc.h | 1 + net/sunrpc/sunrpc_syms.c | 2 ++ net/sunrpc/svcauth.c | 18 ++++++++++++++++++ 3 files changed, 21 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..477890e8b9d8 100644 --- a/net/sunrpc/svcauth.c +++ b/net/sunrpc/svcauth.c @@ -205,3 +205,21 @@ struct auth_domain *auth_domain_find(char *name) return NULL; } EXPORT_SYMBOL_GPL(auth_domain_find); + +void auth_domain_cleanup(void) +{ + /* There should be no auth_domains left at module unload */ + int h; + bool found = false; + + for (h = 0; h < DN_HASHMAX; h++) { + struct auth_domain *hp; + + hlist_for_each_entry(hp, auth_domain_table+h, hash) { + found = true; + printk(KERN_WARNING "sunrpc: domain %s still present at module unload.\n", + hp->name); + } + } + WARN(found, "sunrpc: auth_domain_table not clean -> memory leak\n"); +}