ANDROID: look up vma under RCU in linker_ctx()
madvise_dontneed_single_vma() calls linker_ctx() to detect whether the madvise was initiated by the dynamic linker. This function requires mmap_lock in order to lookup the vma, however with recent changes we do not hold mmap_lock while executing MADV_DONTNEED. Lookup the vma under RCU instead to avoid lockdep warning. Bug: 425827225 Change-Id: Ie5e0243f359b96292d4f32ee3299050b871dc6c5 Signed-off-by: Suren Baghdasaryan <surenb@google.com>
This commit is contained in:
@@ -167,8 +167,6 @@ static __always_inline bool str_has_suffix(const char *str, const char *suffix)
|
||||
* VMAs of the current task.
|
||||
*
|
||||
* Returns true if in linker context, otherwise false.
|
||||
*
|
||||
* Caller must hold mmap lock in read mode.
|
||||
*/
|
||||
static inline bool linker_ctx(void)
|
||||
{
|
||||
@@ -180,14 +178,14 @@ static inline bool linker_ctx(void)
|
||||
if (!regs)
|
||||
return false;
|
||||
|
||||
vma = find_vma(mm, instruction_pointer(regs));
|
||||
vma = lock_vma_under_rcu(mm, instruction_pointer(regs));
|
||||
|
||||
/* Current execution context, the VMA must be present */
|
||||
BUG_ON(!vma);
|
||||
|
||||
file = vma->vm_file;
|
||||
if (!file)
|
||||
return false;
|
||||
goto out;
|
||||
|
||||
if ((vma->vm_flags & VM_EXEC)) {
|
||||
char buf[64];
|
||||
@@ -205,10 +203,13 @@ static inline bool linker_ctx(void)
|
||||
*
|
||||
* Check the base name (linker64).
|
||||
*/
|
||||
if (!strcmp(kbasename(path), "linker64"))
|
||||
if (!strcmp(kbasename(path), "linker64")) {
|
||||
vma_end_read(vma);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
vma_end_read(vma);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user