xen/privcmd: make sure vma is ours before doing anything to it
authorJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Sun, 8 Mar 2009 11:10:00 +0000 (04:10 -0700)
committerJeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Wed, 20 Oct 2010 23:22:32 +0000 (16:22 -0700)
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>
drivers/xen/xenfs/privcmd.c

index 6b602f505363a956e0a453a6317a41539300a3e6..80526afd3063275a185f0b136e0288aafa5c400c 100644 (file)
@@ -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;
@@ -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)) {