On 11/12/24 20:46, Suren Baghdasaryan wrote: > To enable SLAB_TYPESAFE_BY_RCU for vma cache we need to ensure that > object reuse before RCU grace period is over will be detected inside > lock_vma_under_rcu(). > lock_vma_under_rcu() enters RCU read section, finds the vma at the > given address, locks the vma and checks if it got detached or remapped > to cover a different address range. These last checks are there > to ensure that the vma was not modified after we found it but before > locking it. Vma reuse introduces a possibility that in between those > events of finding and locking the vma, it can get detached, reused, > added into a tree and be marked as attached. Current checks will help > detecting cases when: > - vma was reused but not yet added into the tree (detached check) > - vma was reused at a different address range (address check) > If vma is covering a new address range which still includes the address > we were looking for, it's not a problem unless the reused vma was added > into a different address space. Therefore checking that vma->vm_mm is > still the same is the the only missing check to detect vma reuse. Hi, I was wondering if we actually need the detached flag. Couldn't "detached" simply mean vma->vm_mm == NULL and we save 4 bytes? Do we ever need a vma that's detached but still has a mm pointer? I'd hope the places that set detached to false have the mm pointer around so it's not inconvenient.