Commit aed86f8a authored by Schspa Shi's avatar Schspa Shi Committed by Greg Kroah-Hartman

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: bd32889e ("binder: add BINDER_GET_EXTENDED_ERROR ioctl")
Reported-by: syzbot+46fff6434a7f968ecb39@syzkaller.appspotmail.com
Reviewed-by: default avatarCarlos Llamas <cmllamas@google.com>
Signed-off-by: default avatarSchspa Shi <schspa@gmail.com>
Link: https://lore.kernel.org/r/20220518011754.49348-1-schspa@gmail.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dafa5e9a
...@@ -5163,18 +5163,15 @@ static int binder_ioctl_get_freezer_info( ...@@ -5163,18 +5163,15 @@ static int binder_ioctl_get_freezer_info(
static int binder_ioctl_get_extended_error(struct binder_thread *thread, static int binder_ioctl_get_extended_error(struct binder_thread *thread,
void __user *ubuf) void __user *ubuf)
{ {
struct binder_extended_error *ee = &thread->ee; struct binder_extended_error ee;
binder_inner_proc_lock(thread->proc); binder_inner_proc_lock(thread->proc);
if (copy_to_user(ubuf, ee, sizeof(*ee))) { ee = thread->ee;
binder_set_extended_error(&thread->ee, 0, BR_OK, 0);
binder_inner_proc_unlock(thread->proc); binder_inner_proc_unlock(thread->proc);
return -EFAULT;
}
ee->id = 0; if (copy_to_user(ubuf, &ee, sizeof(ee)))
ee->command = BR_OK; return -EFAULT;
ee->param = 0;
binder_inner_proc_unlock(thread->proc);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment