mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Chuck Lever <cel@kernel.org>, Jeff Layton <jlayton@kernel.org>,
	Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>
Cc: NeilBrown <neil@brown.name>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"kernelci.org bot" <bot@kernelci.org>
Subject: [PATCH] SUNRPC: Load the GSS module by OID only when the mechanism is missing
Date: Mon,  9 Nov 2026 22:09:47 -0500	[thread overview]
Message-ID: <20261110030947.179738-1-sashal@kernel.org> (raw)

gss_mech_get_by_OID() calls request_module() before it looks at the
list of registered mechanisms, so every lookup forks a modprobe, even
when the mechanism is already registered or built in.
gss_mech_get_by_name() and gss_mech_get_by_pseudoflavor() only load
the module when the lookup fails.

The read handler of /proc/net/rpc/gss_krb5_enctypes uses this lookup,
so every read() of that file runs modprobe, two per cat. The file is
present in every /proc/<pid>/net/rpc and /proc/<pid>/task/<tid>/net/rpc
directory, and LTP read_all gives each read one second. On a slow board
in KernelCI its workers stall on this file and the test times out.

Look up the mechanism first and call request_module() only when it is
not found, as the other two lookup functions do.

Reported-by: kernelci.org bot <bot@kernelci.org>
Closes: https://d.kernelci.org/test/maestro:6af225865b429d354e253b9b
Fixes: f783288f0cf4 ("SUNRPC: Load GSS kernel module by OID")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 net/sunrpc/auth_gss/gss_mech_switch.c | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c b/net/sunrpc/auth_gss/gss_mech_switch.c
index 78eab245f94a7..d8b6ff9505399 100644
--- a/net/sunrpc/auth_gss/gss_mech_switch.c
+++ b/net/sunrpc/auth_gss/gss_mech_switch.c
@@ -157,14 +157,9 @@ struct gss_api_mech * gss_mech_get_by_name(const char *name)
 	return gm;
 }
 
-struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
+static struct gss_api_mech *_gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
 {
 	struct gss_api_mech	*pos, *gm = NULL;
-	char buf[32];
-
-	if (sprint_oid(obj->data, obj->len, buf, sizeof(buf)) < 0)
-		return NULL;
-	request_module("rpc-auth-gss-%s", buf);
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(pos, &registered_mechs, gm_list) {
@@ -177,6 +172,22 @@ struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
 		}
 	}
 	rcu_read_unlock();
+	return gm;
+}
+
+struct gss_api_mech *gss_mech_get_by_OID(struct rpcsec_gss_oid *obj)
+{
+	struct gss_api_mech *gm;
+	char buf[32];
+
+	if (sprint_oid(obj->data, obj->len, buf, sizeof(buf)) < 0)
+		return NULL;
+
+	gm = _gss_mech_get_by_OID(obj);
+	if (!gm) {
+		request_module("rpc-auth-gss-%s", buf);
+		gm = _gss_mech_get_by_OID(obj);
+	}
 	if (!gm)
 		trace_rpcgss_oid_to_mech(buf);
 	return gm;
-- 
2.53.0


                 reply	other threads:[~2026-11-10  3:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261110030947.179738-1-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=bot@kernelci.org \
    --cc=cel@kernel.org \
    --cc=jlayton@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=netdev@vger.kernel.org \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®