提交 a906d693 编写于 作者: C Chen Feng 提交者: Greg Kroah-Hartman

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: NChen Feng <puck.chen@hisilicon.com>
Signed-off-by: NWei  Dong <weidong2@hisilicon.com>
Signed-off-by: NJunmin Zhao <zhaojunmin@huawei.com>
Reviewed-by: NZhuangluan Su <suzhuangluan@hisilicon.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 70bc916b
...@@ -2737,6 +2737,10 @@ static long binder_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) ...@@ -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", /*pr_info("binder_ioctl: %d:%d %x %lx\n",
proc->pid, current->pid, cmd, arg);*/ 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); trace_binder_ioctl(cmd, arg);
ret = wait_event_interruptible(binder_user_error_wait, binder_stop_on_user_error < 2); 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,6 +2955,7 @@ static int binder_open(struct inode *nodp, struct file *filp)
return -ENOMEM; return -ENOMEM;
get_task_struct(current); get_task_struct(current);
proc->tsk = current; proc->tsk = current;
proc->vma_vm_mm = current->mm;
INIT_LIST_HEAD(&proc->todo); INIT_LIST_HEAD(&proc->todo);
init_waitqueue_head(&proc->wait); init_waitqueue_head(&proc->wait);
proc->default_priority = task_nice(current); proc->default_priority = task_nice(current);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册