binder: don't allow mmap() by process other than proc->tsk
authorAl Viro <viro@zeniv.linux.org.uk>
Wed, 15 Aug 2012 22:23:36 +0000 (18:23 -0400)
committerAl Viro <viro@zeniv.linux.org.uk>
Thu, 27 Sep 2012 01:08:51 +0000 (21:08 -0400)
we really shouldn't do get_files_struct() on a different process
and use it to modify the sucker later on.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
drivers/staging/android/binder.c

index 574e99210c36cd1485012aec3b010dae712f27bf..b9a534c46aac53354bc0fd65707c1d00fe7afa6b 100644 (file)
@@ -2793,6 +2793,9 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
        const char *failure_string;
        struct binder_buffer *buffer;
 
+       if (proc->tsk != current)
+               return -EINVAL;
+
        if ((vma->vm_end - vma->vm_start) > SZ_4M)
                vma->vm_end = vma->vm_start + SZ_4M;
 
@@ -2857,7 +2860,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
        binder_insert_free_buffer(proc, buffer);
        proc->free_async_space = proc->buffer_size / 2;
        barrier();
-       proc->files = get_files_struct(proc->tsk);
+       proc->files = get_files_struct(current);
        proc->vma = vma;
        proc->vma_vm_mm = vma->vm_mm;