mirror of
https://github.com/brain-hackers/linux-brain.git
synced 2024-06-09 23:36:23 +09:00
binder: take read mode of mmap_sem in binder_alloc_free_page()
commit60d4885710
upstream. Restore the behavior of locking mmap_sem for reading in binder_alloc_free_page(), as was first done in commit3013bf62b6
("binder: reduce mmap_sem write-side lock"). That change was inadvertently reverted by commit5cec2d2e58
("binder: fix race between munmap() and direct reclaim"). In addition, change the name of the label for the error path to accurately reflect that we're taking the lock for reading. Backporting note: This fix is only needed when *both* of the commits mentioned above are applied. That's an unlikely situation since they both landed during the development of v5.1 but only one of them is targeted for stable. Fixes:5cec2d2e58
("binder: fix race between munmap() and direct reclaim") Signed-off-by: Tyler Hicks <tyhicks@canonical.com> Acked-by: Todd Kjos <tkjos@android.com> Cc: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
a52262b8a8
commit
b4b9073a8a
|
@ -970,8 +970,8 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
|
|||
mm = alloc->vma_vm_mm;
|
||||
if (!mmget_not_zero(mm))
|
||||
goto err_mmget;
|
||||
if (!down_write_trylock(&mm->mmap_sem))
|
||||
goto err_down_write_mmap_sem_failed;
|
||||
if (!down_read_trylock(&mm->mmap_sem))
|
||||
goto err_down_read_mmap_sem_failed;
|
||||
vma = binder_alloc_get_vma(alloc);
|
||||
|
||||
list_lru_isolate(lru, item);
|
||||
|
@ -986,7 +986,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
|
|||
|
||||
trace_binder_unmap_user_end(alloc, index);
|
||||
}
|
||||
up_write(&mm->mmap_sem);
|
||||
up_read(&mm->mmap_sem);
|
||||
mmput(mm);
|
||||
|
||||
trace_binder_unmap_kernel_start(alloc, index);
|
||||
|
@ -1001,7 +1001,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
|
|||
mutex_unlock(&alloc->mutex);
|
||||
return LRU_REMOVED_RETRY;
|
||||
|
||||
err_down_write_mmap_sem_failed:
|
||||
err_down_read_mmap_sem_failed:
|
||||
mmput_async(mm);
|
||||
err_mmget:
|
||||
err_page_already_freed:
|
||||
|
|
Loading…
Reference in New Issue
Block a user