On Thu, Nov 26, 2026 at 08:00:58PM +0000, Zhenwen Liang wrote: > On Thu, Nov 26, 2026 at 09:07:15PM +0200, Jarkko Sakkinen wrote: > > This will be ultimately addressed by: > [...] > > As then operations will be always drained. > > > > It's actually somewhat tedious to address this particular issue > > without this type of architectural change but I'm open for fixes. > > Thanks. For trees that will not get the series, I think a minimal fix > is possible here, because unregister_key_type() already guarantees that > no new ->update() can run once it returns: key_create_or_update() holds > key_types_sem across __key_update(), key_update() checks > key->type->update under key->sem, and the dead-type GC pass retypes > each remaining key to key_type_dead under key->sem before > unregister_key_type() returns. So every encrypted_rcu_free() has been > queued by then, and an rcu_barrier() after unregister_key_type() in > cleanup_encrypted() waits for all of them. trusted.ko has the same > pattern (trusted_update() uses call_rcu(), and none of the exit paths > waits for pending callbacks), so cleanup_trusted() needs the same. > > I reproduced it in QEMU with KASAN and CONFIG_RCU_LAZY=y: add an > encrypted key, update it 20 times, and unload the module right away. > The rcuop kthread hit int3 at encrypted_rcu_free+0x1 in the freed > module text in 5 of 5 runs. With the barrier, 5 of 5 runs were clean. > > With your series applied, the barrier is still needed as far as I can > see: the GC calls synchronize_rcu() before the module_put() in > key_gc_unused_keys(), and key_gc_flush() is only used by dns_resolver, > NFS idmap, the SMB client and rxrpc. On top of the series, the barrier > could become a key_gc_flush() call. > > I will send two small patches (encrypted, trusted) with Fixes: tags and > Cc: stable; feel free to drop the stable tag if you think it is not > worth it. > > Thanks, > Zhenwen Liang
I saw the patches. I'll look at them with time as soon as I have appropriate bandwidth (might next up til next week not sure). Br, Jarkko
