From 2217ac9e3db1df99306c68ec65443b8c012ecfab Mon Sep 17 00:00:00 2001 From: Vyacheslav Cherkashin Date: Wed, 6 Feb 2013 15:57:14 +0400 Subject: [PATCH] FIX vma checking --- driver/us_proc_inst.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/driver/us_proc_inst.c b/driver/us_proc_inst.c index dd18a30..7d70ba1 100644 --- a/driver/us_proc_inst.c +++ b/driver/us_proc_inst.c @@ -212,6 +212,17 @@ struct dentry *dentry_by_path(const char *path) return dentry; } +static int check_vma(struct vm_area_struct *vma) +{ +#ifndef __ANDROID + return vma->vm_file && !(vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC) || (vma->vm_flags & VM_ACCOUNT) || + !(vma->vm_flags & (VM_WRITE | VM_MAYWRITE)) || + !(vma->vm_flags & (VM_READ | VM_MAYREAD))); +#else // __ANDROID + return vma->vm_file && !(vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC)); +#endif // __ANDROID +} + static int find_task_by_path (const char *path, struct task_struct **p_task, struct list_head *tids) { int found = 0; @@ -240,7 +251,7 @@ static int find_task_by_path (const char *path, struct task_struct **p_task, str continue; vma = mm->mmap; while (vma) { - if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) { + if (check_vma(vma)) { if (vma->vm_file->f_dentry == dentry) { if (!*p_task) { *p_task = task; @@ -972,18 +983,6 @@ static int unregister_us_page_probe(const struct task_struct *task, return err; } -static int check_vma(struct vm_area_struct *vma) -{ -#ifndef __ANDROID - return vma->vm_file && !(vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC) || (vma->vm_flags & VM_ACCOUNT) || - !(vma->vm_flags & (VM_WRITE | VM_MAYWRITE)) || - !(vma->vm_flags & (VM_READ | VM_MAYREAD))); -#else // __ANDROID - return vma->vm_file && !(vma->vm_pgoff != 0 || !(vma->vm_flags & VM_EXEC)); -#endif // __ANDROID -} - - static void install_page_probes(unsigned long page_addr, struct task_struct *task, struct sspt_procs *procs, int atomic) { int lock; @@ -1127,7 +1126,7 @@ static pid_t find_proc_by_task(const struct task_struct *task, const struct dent } for (vma = mm->mmap; vma; vma = vma->vm_next) { - if ((vma->vm_flags & VM_EXECUTABLE) && vma->vm_file) { + if (check_vma(vma)) { if (vma->vm_file->f_dentry == dentry) { return task->tgid; } -- 2.7.4