summaryrefslogtreecommitdiffstats
path: root/drivers/android/binder.c
diff options
context:
space:
mode:
authorChen Feng <puck.chen@hisilicon.com>2016-02-01 14:04:02 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-07 17:34:58 -0800
commita906d6931f3ccaf7de805643190765ddd7378e27 (patch)
tree8a2a1c03c6ea18e631124d36bae2fb8f1badb3de /drivers/android/binder.c
parent70bc916b2c80913753fb188d4daee50a64d21ba0 (diff)
downloadblackbird-op-linux-a906d6931f3ccaf7de805643190765ddd7378e27.tar.gz
blackbird-op-linux-a906d6931f3ccaf7de805643190765ddd7378e27.zip
android: binder: Sanity check at binder ioctl
Sanity check at binder ioctl function, Only allow the shared mm_struct to use the same binder-object to do binder operate. And add proc->vma_vm_mm = current->mm at the open function. The libbinder do ioctl before mmap called. V2: Fix compile error for error commit V3: Change the condition to proc->vma_vm_mm Signed-off-by: Chen Feng <puck.chen@hisilicon.com> Signed-off-by: Wei Dong <weidong2@hisilicon.com> Signed-off-by: Junmin Zhao <zhaojunmin@huawei.com> Reviewed-by: Zhuangluan Su <suzhuangluan@hisilicon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android/binder.c')
-rw-r--r--drivers/android/binder.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index a39e85f9efa9..f080a8b7659b 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -2737,6 +2737,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
/*pr_info("binder_ioctl: %d:%d %x %lx\n",
proc->pid, current->pid, cmd, arg);*/
+ if (unlikely(current->mm != proc->vma_vm_mm)) {
+ pr_err("current mm mismatch proc mm\n");
+ return -EINVAL;
+ }
trace_binder_ioctl(cmd, arg);
ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2);
@@ -2951,6 +2955,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
return -ENOMEM;
get_task_struct(current);
proc->tsk = current;
+ proc->vma_vm_mm = current->mm;
INIT_LIST_HEAD(&proc->todo);
init_waitqueue_head(&proc->wait);
proc->default_priority = task_nice(current);
OpenPOWER on IntegriCloud