* [PATCH v3] android: binder: Sanity check at binder ioctl
@ 2016-02-01 6:04 Chen Feng
2016-02-02 12:36 ` Chen Feng
0 siblings, 1 reply; 2+ messages in thread
From: Chen Feng @ 2016-02-01 6:04 UTC (permalink / raw)
To: gregkh, arve, riandrews, devel, linux-kernel, wangjing6, weidong2,
zhaojunmin, puck.chen
Cc: suzhuangluan, puck.chen, w.f, linuxarm
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>
---
drivers/android/binder.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index a39e85f..f080a8b 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);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] android: binder: Sanity check at binder ioctl
2016-02-01 6:04 [PATCH v3] android: binder: Sanity check at binder ioctl Chen Feng
@ 2016-02-02 12:36 ` Chen Feng
0 siblings, 0 replies; 2+ messages in thread
From: Chen Feng @ 2016-02-02 12:36 UTC (permalink / raw)
To: gregkh, arve, riandrews, devel, linux-kernel, wangjing6, weidong2,
zhaojunmin, kernel-team, kirill.shutemov, oleg, hpa, luto,
dave.hansen, mingo, minchan, tglx, akpm, oleg, hpa
Cc: suzhuangluan, puck.chen, w.f, linuxarm
Add android kernel team.
On 2016/2/1 14:04, Chen Feng wrote:
> 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>
> ---
> drivers/android/binder.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index a39e85f..f080a8b 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);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-02-02 12:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-01 6:04 [PATCH v3] android: binder: Sanity check at binder ioctl Chen Feng
2016-02-02 12:36 ` Chen Feng
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox