On 2/5/21 10:28 AM, Jarkko Sakkinen wrote: > This has been shown in tests: > > [ +0.000008] WARNING: CPU: 3 PID: 7620 at kernel/rcu/srcutree.c:374 cleanup_srcu_struct+0xed/0x100 > > There are two functions that drain encl->mm_list: > > - sgx_release() (i.e. VFS release) removes the remaining mm_list entries. > - sgx_mmu_notifier_release() removes mm_list entry for the registered > process, if it still exists. Jarkko, I like your approach. This actually has the potential to be a lot more understandable than the fix we settled on before. But I think the explanation needs some tweaking, and I think I can take it a step further to make it even more straightforward. The issue here isn't *really* mm_list, it's this: encl_mm->encl = encl; That literally establishes a encl_mm to encl reference and needs a reference count. That reference remains until 'encl_mm' is freed. I don't think mm_list needs to even be taken into account. The most straightforward way to fix this is to take a refcount at "encl_mm->encl = encl" and release it at kfree(encl_mm). That makes a *lot* of logical sense to me, and it's also trivial to audit. Totally untested patch attached (adapted directly from yours).