diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-09-16 13:31:39 -0400 |
---|---|---|
committer | Oleg Nesterov <oleg@redhat.com> | 2012-09-29 15:21:54 -0400 |
commit | e40cfce626a5537994058ee9a940dcfdc0f68ef0 (patch) | |
tree | ce9a24a51906fb3437ea0f08851e4dfb4671aa0b /kernel/events | |
parent | 78a320542e6cdb2800cd736b2d136e4261d34f43 (diff) |
uprobes: Restrict valid_vma(false) to skip VM_SHARED vmas
valid_vma(false) ignores ->vm_flags, this is not actually right.
We should never try to write into MAP_SHARED mapping, this can
confuse an apllication which actually writes to ->vm_file.
With this patch valid_vma(false) ignores VM_WRITE only but checks
other (immutable) bits checked by valid_vma(true). This can also
speedup uprobe_munmap() and uprobe_unregister().
Note: even after this patch _unregister can confuse the probed
application if it does mprotect(PROT_WRITE) after _register and
installs "int3", but this is hardly possible to avoid and this
doesn't differ from gdb case.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Diffstat (limited to 'kernel/events')
-rw-r--r-- | kernel/events/uprobes.c | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index a9de40815391..8d182bdecc2e 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -100,17 +100,12 @@ struct uprobe { | |||
100 | */ | 100 | */ |
101 | static bool valid_vma(struct vm_area_struct *vma, bool is_register) | 101 | static bool valid_vma(struct vm_area_struct *vma, bool is_register) |
102 | { | 102 | { |
103 | if (!vma->vm_file) | 103 | vm_flags_t flags = VM_HUGETLB | VM_MAYEXEC | VM_SHARED; |
104 | return false; | ||
105 | |||
106 | if (!is_register) | ||
107 | return true; | ||
108 | 104 | ||
109 | if ((vma->vm_flags & (VM_HUGETLB | VM_WRITE | VM_MAYEXEC | VM_SHARED)) | 105 | if (is_register) |
110 | == VM_MAYEXEC) | 106 | flags |= VM_WRITE; |
111 | return true; | ||
112 | 107 | ||
113 | return false; | 108 | return vma->vm_file && (vma->vm_flags & flags) == VM_MAYEXEC; |
114 | } | 109 | } |
115 | 110 | ||
116 | static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) | 111 | static unsigned long offset_to_vaddr(struct vm_area_struct *vma, loff_t offset) |