binder: fix atomic sleep when get extended error
PATCH v2 1/1 binder: fix atomic sleep when get extended error
binder_inner_proc_lock(thread->proc) is a spin lock, copy_to_user can't be called with in this lock.
Copy it as a local variable to fix it.
Reported-by [email protected]
Fixes bd32889e841c ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")
Signed-off-by Schspa Shi <[email protected]>
---
Changelog:
v1 -> v2:
- Remove the retry as Carlos Llamas adviced.
- Use binder_set_extended_error to reset the error info.
--- drivers/android/binder.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
drivers/android/binder.c +6 -9
@@ -5162,19 +5162,16 @@ static int binder_ioctl_get_freezer_info(static int binder_ioctl_get_extended_error (struct binder_thread *thread,void __user *ubuf) { -struct binder_extended_error *ee = &thread->ee; +struct binder_extended_error ee;binder_inner_proc_lock (thread->proc); -if (copy_to_user (ubuf, ee,sizeof (*ee))) { -binder_inner_proc_unlock (thread->proc); -return -EFAULT ; - } - - ee->id =0 ; - ee->command =BR_OK ; - ee->param =0 ; + ee = thread->ee; +binder_set_extended_error (&thread->ee,0 ,BR_OK ,0 );binder_inner_proc_unlock (thread->proc); +if (copy_to_user (ubuf, &ee,sizeof (ee))) +return -EFAULT ; +return 0 ; }
Signature · 1 line
2.24.3 (Apple Git-128)
Quoted 9 lines · Schspa Shi
binder_inner_proc_lock(thread->proc)is a spin lock,copy_to_usercan't be called with in this lock.Copy it as a local variable to fix it.
Reported-by [email protected]Fixes bd32889e841c ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")Signed-off-by Schspa Shi <[email protected]>
Quoted 7 lines
---
Changelog:
v1 -> v2:
- Remove the retry as Carlos Llamas adviced.
- Usebinder_set_extended_errorto reset the error info.
---
LGTM, thanks.
Reviewed-by Carlos Llamas <[email protected]>
--
Carlos Llamas