Skip to contentSkip to conversation

android: binder: Sanity check at binder ioctl

PATCH RESEND Superseded Chen Feng 2 participants 5 messages Jan 19, 2016 Android drivers

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Chen Feng

author
#0 lore raw

PATCH RESEND 1/1 android: binder: Sanity check at binder ioctl

When a process fork a child process, we should not allow the child process use the binder which opened by parent process.

But if the binder-object creater is a thread of one process who exit, the other thread can also use this binder-object normally. We can distinguish this by the member proc->tsk->mm.
If the thread exit the tsk->mm will be NULL.

proc->tsk->mm != current->mm && proc->tsk->mm

So only allow the shared mm_struct to use the same binder-object and check the existence of mm_struct.

---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/android/binder.c +2 -0
index a39e85f..279063c 100644
@@ -2736,6 +2736,8 @@ 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(proc->tsk->mm != current->mm && proc->tsk->mm))
+		return -EINVAL;
 
 	trace_binder_ioctl(cmd, arg);
 
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 13 lines · Chen Feng

When a process fork a child process, we should not allow the child process use the binder which opened by parent process.

But if the binder-object creater is a thread of one process who exit, the other thread can also use this binder-object normally. We can distinguish this by the member proc->tsk->mm.
If the thread exit the tsk->mm will be NULL.

proc->tsk->mm != current->mm && proc->tsk->mm

So only allow the shared mm_struct to use the same binder-object and check the existence of mm_struct.

Quoted 7 lines
---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)

Why resend? What changed from the previous version?

greg k-h

author
#2 lore raw
Quoted 22 lines · Greg KH
Quoted 13 lines · Chen Feng

When a process fork a child process, we should not allow the child process use the binder which opened by parent process.

But if the binder-object creater is a thread of one process who exit, the other thread can also use this binder-object normally. We can distinguish this by the member proc->tsk->mm.
If the thread exit the tsk->mm will be NULL.

proc->tsk->mm != current->mm && proc->tsk->mm

So only allow the shared mm_struct to use the same binder-object and check the existence of mm_struct.

Quoted 7 lines
---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 2 lines

Why resend? What changed from the previous version?

My fault, it's my error commit.
mistake the current->mm with current->tsk->mm.
The robot-compile finds out this error.

Quoted 4 lines

greg k-h

.

maintainer
#3 lore raw
Quoted 25 lines · chenfeng
Quoted 22 lines · Greg KH
Quoted 20 lines · Chen Feng

When a process fork a child process, we should not allow the child process use the binder which opened by parent process.

But if the binder-object creater is a thread of one process who exit, the other thread can also use this binder-object normally. We can distinguish this by the member proc->tsk->mm.
If the thread exit the tsk->mm will be NULL.

proc->tsk->mm != current->mm && proc->tsk->mm

So only allow the shared mm_struct to use the same binder-object and check the existence of mm_struct.

---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)
Quoted 5 lines
Quoted 2 lines

Why resend? What changed from the previous version?

My fault, it's my error commit.
mistake the current->mm with current->tsk->mm.
The robot-compile finds out this error.

Then please make it a 'v2' patch, and say what you changed, otherwise I'll assume it's identical to the first patch you sent in.

And how did you test the first patch if it couldn't even compile?

greg k-h

author
#4 lore raw
Quoted 28 lines · Greg KH
Quoted 27 lines · chenfeng
Quoted 24 lines · Greg KH
Quoted 13 lines · Chen Feng

When a process fork a child process, we should not allow the child process use the binder which opened by parent process.

But if the binder-object creater is a thread of one process who exit, the other thread can also use this binder-object normally. We can distinguish this by the member proc->tsk->mm.
If the thread exit the tsk->mm will be NULL.

proc->tsk->mm != current->mm && proc->tsk->mm

So only allow the shared mm_struct to use the same binder-object and check the existence of mm_struct.

Quoted 7 lines
---
 drivers/android/binder.c | 2 ++
 1 file changed, 2 insertions(+)

Why resend? What changed from the previous version?

Quoted 9 lines
Quoted 3 lines

My fault, it's my error commit.
mistake the current->mm with current->tsk->mm.
The robot-compile finds out this error.

Then please make it a 'v2' patch, and say what you changed, otherwise I'll assume it's identical to the first patch you sent in.

And how did you test the first patch if it couldn't even compile?

It works well on our platform with hundreds of mobile phone. Since our working branch is not mainline,and the patch is send for mainline review.

I made a mistake while making the patch. I will send a new V2 for this patch. Thanks!

Quoted 4 lines

greg k-h

.