BACKPORT: binder: add BINDER_GET_EXTENDED_ERROR ioctl

Provide a userspace mechanism to pull precise error information upon
failed operations. Extending the current error codes returned by the
interfaces allows userspace to better determine the course of action.
This could be for instance, retrying a failed transaction at a later
point and thus offloading the error handling from the driver.

Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Acked-by: Todd Kjos <tkjos@google.com>
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Link: https://lore.kernel.org/r/20220429235644.697372-3-cmllamas@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: Ibd0f984984e0425335e5a9579c6d6d8214b8cb56

# Conflicts:
#	drivers/android/binder.c
fourteen
Jenna 5 months ago
parent e65858ca7d
commit b24b3276f7
  1. 15
      drivers/android/binder.c

@ -5168,15 +5168,18 @@ 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;
struct binder_extended_error *ee = &thread->ee;
binder_inner_proc_lock(thread->proc);
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)))
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;
binder_inner_proc_unlock(thread->proc);
return 0;
}

Loading…
Cancel
Save