Red ebony in the kernel is not protected?

In the Linux kernel, Linux uses both a linked list and a red-black tree to store process memory areas. find_vma is a function that finds the first region of memory, the vm_end field of which is larger than the address passed through red ebony. However, I believe that there is no protection (e.g. blocking) for red ebony inside find_vma (). What if another thread calls the rb_erase function to delete some item on the tree at the same time?

+5
source share
1 answer

Yes, the call to the find_vma function is protected from simultaneous access through a semaphore. The scheduler also uses a function with semaphore calls.

2209 down_read(&mm->mmap_sem); 2210 vma = find_vma(mm, start); .... up_read(&mm->mmap_sem); mmap_sem is used to protect this function call which is a read-write semaphore. struct rw_semaphore mmap_sem; defined inside struct mm_struct. 
+2
source

Source: https://habr.com/ru/post/1236952/


All Articles