binder: use group leader instead of open thread

The binder allocator assumes that the thread that
called binder_open will never die for the lifetime of
that proc. That thread is normally the group_leader,
however it may not be. Use the group_leader instead
of current.

Bug: 35707103
Test: Created test case to open with temporary thread
Change-Id: Id693f74b3591f3524a8c6e9508e70f3e5a80c588
Signed-off-by: Todd Kjos <tkjos@google.com>
This commit is contained in:
Todd Kjos
2017-02-22 19:11:19 -08:00
committed by Thierry Strudel
parent e14ae0a106
commit 53d223b94f
2 changed files with 4 additions and 4 deletions

View File

@@ -3729,7 +3729,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
struct binder_proc *proc = filp->private_data;
const char *failure_string;
if (proc->tsk != current)
if (proc->tsk != current->group_leader)
return -EINVAL;
if ((vma->vm_end - vma->vm_start) > SZ_4M)
@@ -3775,8 +3775,8 @@ static int binder_open(struct inode *nodp, struct file *filp)
if (proc == NULL)
return -ENOMEM;
get_task_struct(current);
proc->tsk = current;
get_task_struct(current->group_leader);
proc->tsk = current->group_leader;
binder_init_worklist(&proc->todo);
init_waitqueue_head(&proc->wait);
proc->default_priority = task_nice(current);

View File

@@ -662,7 +662,7 @@ void binder_alloc_vma_close(struct binder_alloc *alloc)
void binder_alloc_init(struct binder_alloc *alloc)
{
alloc->tsk = current;
alloc->tsk = current->group_leader;
alloc->pid = current->group_leader->pid;
mutex_init(&alloc->mutex);
}