aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/android
diff options
context:
space:
mode:
authorChen Feng <puck.chen@hisilicon.com>2016-02-01 01:04:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-07 20:34:58 -0500
commita906d6931f3ccaf7de805643190765ddd7378e27 (patch)
tree8a2a1c03c6ea18e631124d36bae2fb8f1badb3de /drivers/android
parent70bc916b2c80913753fb188d4daee50a64d21ba0 (diff)
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')
-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)
2737 /*pr_info("binder_ioctl: %d:%d %x %lx\n", 2737 /*pr_info("binder_ioctl: %d:%d %x %lx\n",
2738 proc->pid, current->pid, cmd, arg);*/ 2738 proc->pid, current->pid, cmd, arg);*/
2739 2739
2740 if (unlikely(current->mm != proc->vma_vm_mm)) {
2741 pr_err("current mm mismatch proc mm\n");
2742 return -EINVAL;
2743 }
2740 trace_binder_ioctl(cmd, arg); 2744 trace_binder_ioctl(cmd, arg);
2741 2745
2742 ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); 2746 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)
2951 return -ENOMEM; 2955 return -ENOMEM;
2952 get_task_struct(current); 2956 get_task_struct(current);
2953 proc->tsk = current; 2957 proc->tsk = current;
2958 proc->vma_vm_mm = current->mm;
2954 INIT_LIST_HEAD(&proc->todo); 2959 INIT_LIST_HEAD(&proc->todo);
2955 init_waitqueue_head(&proc->wait); 2960 init_waitqueue_head(&proc->wait);
2956 proc->default_priority = task_nice(current); 2961 proc->default_priority = task_nice(current);