diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-07-29 14:22:44 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2012-07-30 05:27:24 -0400 |
commit | f4d6dfe55115efe981b4b5f37183ddccaaa792f0 (patch) | |
tree | 2d81b1b5a17334895282b42de6134b4e2dcf9f24 /kernel | |
parent | cb113b47d098185f3f1f67e8300d05ddce842b66 (diff) |
uprobes: Fix register_for_each_vma()->vma_address() check
1. register_for_each_vma() checks that vma_address() == vaddr,
but this is not enough. We should also ensure that
vaddr >= vm_start, find_vma() guarantees "vaddr < vm_end" only.
2. After the prevous changes, register_for_each_vma() is the
only reason why vma_address() has to return loff_t, all other
users know that we have the valid mapping at this offset and
thus the overflow is not possible.
Change the code to use vaddr_to_offset() instead, imho this looks
more clean/understandable and now we can change vma_address().
3. While at it, remove the unnecessary type-cast.
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar.vnet.ibm.com>
Cc: Anton Arapov <anton@redhat.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/20120729182244.GA20362@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/events/uprobes.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index b03256cced52..cdc3c951251c 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
@@ -823,12 +823,13 @@ static int register_for_each_vma(struct uprobe *uprobe, bool is_register) | |||
823 | goto free; | 823 | goto free; |
824 | 824 | ||
825 | down_write(&mm->mmap_sem); | 825 | down_write(&mm->mmap_sem); |
826 | vma = find_vma(mm, (unsigned long)info->vaddr); | 826 | vma = find_vma(mm, info->vaddr); |
827 | if (!vma || !valid_vma(vma, is_register)) | 827 | if (!vma || !valid_vma(vma, is_register) || |
828 | vma->vm_file->f_mapping->host != uprobe->inode) | ||
828 | goto unlock; | 829 | goto unlock; |
829 | 830 | ||
830 | if (vma->vm_file->f_mapping->host != uprobe->inode || | 831 | if (vma->vm_start > info->vaddr || |
831 | vma_address(vma, uprobe->offset) != info->vaddr) | 832 | vaddr_to_offset(vma, info->vaddr) != uprobe->offset) |
832 | goto unlock; | 833 | goto unlock; |
833 | 834 | ||
834 | if (is_register) { | 835 | if (is_register) { |