diff options
author | Schspa Shi <schspa@gmail.com> | 2022-05-18 04:17:54 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-05-19 19:41:33 +0300 |
commit | aed86f8add0e3f63a033861f247c9ae956b72c92 (patch) | |
tree | c2b1088b38013f9c542130de9cf107fbaa3a87ee /drivers/android | |
parent | dafa5e9ab8b5b31d64c0ded188d95f8bb6be9746 (diff) | |
download | linux-aed86f8add0e3f63a033861f247c9ae956b72c92.tar.xz |
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.
Fixes: bd32889e841c ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")
Reported-by: syzbot+46fff6434a7f968ecb39@syzkaller.appspotmail.com
Reviewed-by: Carlos Llamas <cmllamas@google.com>
Signed-off-by: Schspa Shi <schspa@gmail.com>
Link: https://lore.kernel.org/r/20220518011754.49348-1-schspa@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r-- | drivers/android/binder.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/android/binder.c b/drivers/android/binder.c index 9e36608eac6c..77d0b17cb646 100644 --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -5163,19 +5163,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; } |