From: sashiko-bot@kernel.org
To: "Jarkko Sakkinen" <jarkko@kernel.org>,
"David Howells" <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org, linux-s390@vger.kernel.org,
linux-security-module@vger.kernel.org,
samba-technical@lists.samba.org,
"Alexander Gordeev" <agordeev@linux.ibm.com>,
"Anna Schumaker" <anna@kernel.org>,
"Bharath SM" <bharathsm@microsoft.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Biggers" <ebiggers@kernel.org>,
"Eric Dumazet" <edumazet@kernel.org>,
"Heiko Carstens" <hca@linux.ibm.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"James Bottomley" <James.Bottomley@HansenPartnership.com>,
"James Morris" <jmorris@namei.org>,
"Marc Dionne" <marc.dionne@auristor.com>,
"Mimi Zohar" <zohar@linux.ibm.com>,
"Namjae Jeon" <linkinjeon@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Paul Moore" <paul@paul-moore.com>,
"Paulo Alcantara" <pc@manguebit.org>,
"Ronnie Sahlberg" <ronniesahlberg@gmail.com>,
"Serge E. Hallyn" <serge@hallyn.com>,
"Shyam Prasad N" <sprasad@microsoft.com>,
"Simon Horman" <horms@kernel.org>,
"Sumit Garg" <sumit.garg@kernel.org>,
"Sven Schnelle" <svens@linux.ibm.com>,
"Tom Talpey" <tom@talpey.com>,
"Trond Myklebust" <trondmy@kernel.org>,
"Vasily Gorbik" <gor@linux.ibm.com>,
"Chuck Lever" <cel@kernel.org>,
"Jeff Layton" <jlayton@kernel.org>
Subject: Re: [RFC PATCH v3 03/11] NFSv4: Clear idmap keyring cache when the last client unloads
Date: Fri, 06 Nov 2026 00:54:04 +0000 [thread overview]
Message-ID: <sashiko-outbox-200458@kernel.org> (raw)
In-Reply-To: <20261105005311.804098-4-jarkko@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] NFSv4: nfs_idmap_delete() flushes !WQ_MEM_RECLAIM work from reclaim context
--
commit 4e575974579117eaf53b52bd9cc0b5c049e02d3d
Author: Jarkko Sakkinen <jarkko@kernel.org>
NFSv4: Clear idmap keyring cache when the last client unloads
This commit tracks active NFSv4 idmap instances and clears the
id_resolver_cache thread keyring (followed by flushing key garbage
collection) when the last NFS client is destroyed.
> diff --git a/fs/nfs/nfs4idmap.c b/fs/nfs/nfs4idmap.c
> index bc397110d977f..c88444cc6bf68 100644
> --- a/fs/nfs/nfs4idmap.c
> +++ b/fs/nfs/nfs4idmap.c
[ ... ]
> @@ -483,6 +492,7 @@ void
> nfs_idmap_delete(struct nfs_client *clp)
> {
> struct idmap *idmap = clp->cl_idmap;
> + int ret;
>
> if (!idmap)
> return;
> @@ -493,6 +503,17 @@ nfs_idmap_delete(struct nfs_client *clp)
> rpc_destroy_pipe_data(idmap->idmap_pipe);
> put_user_ns(idmap->user_ns);
> kfree(idmap);
> +
> + mutex_lock(&nfs_idmap_cache_mutex);
> + if (--nfs_idmap_users == 0) {
> + ret = keyring_clear(id_resolver_cache->thread_keyring);
> + if (ret)
> + pr_warn_ratelimited("NFS: Failed to clear idmap cache: %d; cache pins remain\n",
> + ret);
> + else
> + key_gc_flush();
> + }
> + mutex_unlock(&nfs_idmap_cache_mutex);
> }
[Severity: High]
Can calling key_gc_flush() from nfs_idmap_delete() trigger a workqueue
check_flush_dependency() warning and risk a memory-reclaim deadlock?
In security/keys/gc.c, key_gc_flush() flushes key_gc_work, which is queued
via schedule_work() onto system_percpu_wq (a workqueue without
WQ_MEM_RECLAIM):
security/keys/gc.c:key_gc_flush() {
do {
rcu_barrier();
} while (flush_work(&key_gc_work));
}
However, the final reference on clp->cl_count can be dropped from
workqueues allocated with WQ_MEM_RECLAIM or from tasks running with
PF_MEMALLOC set:
nfs41_free_stateid_release() / nfs41_sequence_release() [on rpciod_workqueue, WQ_MEM_RECLAIM, and potentially PF_MEMALLOC via __rpc_execute()]
or nfs_local_probe_async_work() / pnfs_generic_rw_release() [on nfsiod_workqueue, WQ_MEM_RECLAIM]
-> nfs_put_client()
-> nfs4_free_client()
-> nfs4_shutdown_client()
-> nfs_idmap_delete()
-> key_gc_flush()
-> flush_work(&key_gc_work)
When the last NFSv4 client is freed through one of these asynchronous paths
after id_resolver_cache->thread_keyring has been populated, flushing
key_gc_work on system_percpu_wq from a WQ_MEM_RECLAIM worker or PF_MEMALLOC
context will trip the WARN_ONCE() in kernel/workqueue.c:
check_flush_dependency() and could deadlock under memory pressure.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105005311.804098-1-jarkko@kernel.org?part=3
next prev parent reply other threads:[~2026-11-06 0:54 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 0:52 [RFC PATCH v3 00/11] KEYS: Sanitize the garbage collector Jarkko Sakkinen
2026-11-05 0:53 ` [RFC PATCH v3 01/11] KEYS: Add key_gc_flush() for draining RCU callbacks Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 02/11] dns_resolver: Move the key type into a separate module Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 03/11] NFSv4: Clear idmap keyring cache when the last client unloads Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot [this message]
2026-11-05 0:53 ` [RFC PATCH v3 04/11] smb: client: Clear idmap/SPNEGO caches when the last session is unloaded Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 05/11] s390/cert_store: Start tracking subsystem keys Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 06/11] KEYS: trusted: TEE: Disable sysfs bind attributes Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 07/11] KEYS: trusted: TEE: Synchronize session lifetime Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 08/11] rxrpc: Move key types to their own module Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 09/11] KEYS: Pin the backing kernel module for a key type Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 10/11] KEYS: Remove key_type_dead Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 0:53 ` [RFC PATCH v3 11/11] KEYS: key_garbage_collector(): process in chunks Jarkko Sakkinen
2026-11-06 0:54 ` sashiko-bot
2026-11-05 1:04 ` [RFC PATCH v3 00/11] KEYS: Sanitize the garbage collector Jarkko Sakkinen
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=sashiko-outbox-200458@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=agordeev@linux.ibm.com \
--cc=anna@kernel.org \
--cc=bharathsm@microsoft.com \
--cc=borntraeger@linux.ibm.com \
--cc=cel@kernel.org \
--cc=davem@davemloft.net \
--cc=dhowells@redhat.com \
--cc=ebiggers@kernel.org \
--cc=edumazet@kernel.org \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=horms@kernel.org \
--cc=jarkko@kernel.org \
--cc=jlayton@kernel.org \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linkinjeon@kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=marc.dionne@auristor.com \
--cc=pabeni@redhat.com \
--cc=paul@paul-moore.com \
--cc=pc@manguebit.org \
--cc=ronniesahlberg@gmail.com \
--cc=samba-technical@lists.samba.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=serge@hallyn.com \
--cc=sprasad@microsoft.com \
--cc=sumit.garg@kernel.org \
--cc=svens@linux.ibm.com \
--cc=tom@talpey.com \
--cc=trondmy@kernel.org \
--cc=zohar@linux.ibm.com \
/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