Skip to contentSkip to conversation

ANDROID: binder: correct the cmd print for BINDER_WORK_RETURN_ERROR

PATCH Superseded 宋金时 2 participants 3 messages May 9, 2018 – May 10, 2018 Android drivers

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

宋金时

author
#0 lore raw

PATCH 1/1 ANDROID: binder: correct the cmd print for BINDER_WORK_RETURN_ERROR

In case of the BINDER_WORK_RETURN_ERROR the cmd is no assignment, so it's value will be old value or dirty value, before modifying e->cmd, assign the value of the e->cmd to cmd to ensure the correct print of binder_stat_br.

---

drivers/android/binder.c +1 -0
index 4ffc84d..acd7d44a 100644
@@ -4086,6 +4086,7 @@
 			struct binder_error *e = container_of(
 					w, struct binder_error, work);
 
+			cmd = e->cmd;
 			WARN_ON(e->cmd == BR_OK);
 			binder_inner_proc_unlock(proc);
 			if (put_user(e->cmd, (uint32_t __user *)ptr))
#1 lore raw
Quoted 4 lines · 宋金时

In case of the BINDER_WORK_RETURN_ERROR the cmd is no assignment, so it's value will be old value or dirty value, before modifying e->cmd, assign the value of the e->cmd to cmd to ensure the correct print of binder_stat_br.

That's not the problem... the problem is that e->cmd is unconditionally set to BR_OK prior to the call to binder_stat_br(proc, thread, e->cmd) so the reported cmd is always BR_OK.

Quoted 8 lines

---

drivers/android/binder.c +0 -0
index 4ffc84d..acd7d44a 100644

drivers/android/binder.c line 4092

Quoted 7 lines
drivers/android/binder.c +1 -0
@@ -4086,6 +4086,7 @@
                         struct binder_error *e = container_of(
                                         w, struct binder_error, work);
 
+                       cmd = e->cmd;
                         WARN_ON(e->cmd == BR_OK);
                         binder_inner_proc_unlock(proc);
                         if (put_user(e->cmd, (uint32_t __user *)ptr))

Don't you also need to use cmd in the call to binder_state_br() below?

- binder_stat_br(proc, thread, e->cmd);
+ binder_stat_br(proc, thread, cmd);

-Todd

author
#2 lore raw

OK,this patch is based on the downstream android kernel4.4 version, not yet include the latest changes, let me update the patch to base on the latest upstream, Tks.

________________________________________
发件人: Todd Kjos <[email protected]>
发送时间: 2018年5月10日 2:08
收件人: 宋金时
抄送: Greg Kroah-Hartman; Martijn Coenen; Arve Hjønnevåg; LKML
主题: Re: [PATCH] ANDROID: binder: correct the cmd print for BINDER_WORK_RETURN_ERROR

Quoted 4 lines · 宋金时

In case of the BINDER_WORK_RETURN_ERROR the cmd is no assignment, so it's value will be old value or dirty value, before modifying e->cmd, assign the value of the e->cmd to cmd to ensure the correct print of binder_stat_br.

That's not the problem... the problem is that e->cmd is unconditionally set to BR_OK prior to the call to binder_stat_br(proc, thread, e->cmd) so the reported cmd is always BR_OK.

Quoted 8 lines

---

drivers/android/binder.c +0 -0
index 4ffc84d..acd7d44a 100644

drivers/android/binder.c line 4092

Quoted 7 lines
drivers/android/binder.c +1 -0
@@ -4086,6 +4086,7 @@
                         struct binder_error *e = container_of(
                                         w, struct binder_error, work);
 
+                       cmd = e->cmd;
                         WARN_ON(e->cmd == BR_OK);
                         binder_inner_proc_unlock(proc);
                         if (put_user(e->cmd, (uint32_t __user *)ptr))

Don't you also need to use cmd in the call to binder_state_br() below?

- binder_stat_br(proc, thread, e->cmd);
+ binder_stat_br(proc, thread, cmd);

-Todd