Skip to content

Commit

Permalink
xen/privcmd: make sure vma is ours before doing anything to it
Browse files Browse the repository at this point in the history
Test vma->vm_ops is our operations to make sure we created it.
We don't want to stomp on other random vmas.

[ Impact: bugfix; prevent ioctl from affecting other mappings ]

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
  • Loading branch information
Jeremy Fitzhardinge committed Oct 20, 2010
1 parent 441c741 commit f31fdf5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/xen/xenfs/privcmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ static int mmap_return_errors(void *data, void *state)
return 0;
}

static struct vm_operations_struct privcmd_vm_ops;

static long privcmd_ioctl_mmap_batch(void __user *udata)
{
int ret;
Expand Down Expand Up @@ -341,6 +343,7 @@ static long privcmd_ioctl_mmap_batch(void __user *udata)
vma = find_vma(mm, m.addr);
ret = -EINVAL;
if (!vma ||
vma->vm_ops != &privcmd_vm_ops ||
(m.addr != vma->vm_start) ||
((m.addr + (nr_pages << PAGE_SHIFT)) != vma->vm_end) ||
!privcmd_enforce_singleshot_mapping(vma)) {
Expand Down

0 comments on commit f31fdf5

Please sign in to comment.