* [PATCH v2] binder: fix atomic sleep when get extended error
@ 2022-05-18 1:17 Schspa Shi
2022-05-18 1:27 ` Carlos Llamas
0 siblings, 1 reply; 2+ messages in thread
From: Schspa Shi @ 2022-05-18 1:17 UTC (permalink / raw)
To: gregkh, arve, tkjos, maco, joel, brauner, hridya, surenb, cmllamas
Cc: linux-kernel, schspa, syzbot+46fff6434a7f968ecb39
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: syzbot+46fff6434a7f968ecb39@syzkaller.appspotmail.com
Fixes: bd32889e841c ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")
Signed-off-by: Schspa Shi <schspa@gmail.com>
---
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(-)
diff --git a/drivers/android/binder.c b/drivers/android/binder.c
index d9253b2a7bd9..1a6b7a8c8346 100644
--- a/drivers/android/binder.c
+++ b/drivers/android/binder.c
@@ -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;
}
--
2.24.3 (Apple Git-128)
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] binder: fix atomic sleep when get extended error
2022-05-18 1:17 [PATCH v2] binder: fix atomic sleep when get extended error Schspa Shi
@ 2022-05-18 1:27 ` Carlos Llamas
0 siblings, 0 replies; 2+ messages in thread
From: Carlos Llamas @ 2022-05-18 1:27 UTC (permalink / raw)
To: Schspa Shi
Cc: gregkh, arve, tkjos, maco, joel, brauner, hridya, surenb,
linux-kernel, syzbot+46fff6434a7f968ecb39
On Wed, May 18, 2022 at 09:17:54AM +0800, Schspa Shi wrote:
> 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: syzbot+46fff6434a7f968ecb39@syzkaller.appspotmail.com
> Fixes: bd32889e841c ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")
> Signed-off-by: Schspa Shi <schspa@gmail.com>
>
> ---
>
> Changelog:
> v1 -> v2:
> - Remove the retry as Carlos Llamas adviced.
> - Use binder_set_extended_error to reset the error info.
> ---
LGTM, thanks.
Reviewed-by: Carlos Llamas <cmllamas@google.com>
--
Carlos Llamas
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-05-18 1:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-18 1:17 [PATCH v2] binder: fix atomic sleep when get extended error Schspa Shi
2022-05-18 1:27 ` Carlos Llamas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.