Re: [PATCH v2] rust_binder: fix BINDER_GET_EXTENDED_ERROR

From: Alice Ryhl

Date: Thu Jun 04 2026 - 09:07:33 EST


On Thu, Jun 04, 2026 at 11:37:07AM +0000, Alice Ryhl wrote:
> This code currently copies the ExtendedError struct to the stack,
> modifies the copy, and then doesn't modify the original. Thus, fix it.
>
> Furthermore, errors when replying must be delivered directly to the
> remote thread, so update deliver_reply() to take an extended error
> argument.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Alice Ryhl <aliceryhl@xxxxxxxxxx>

> BR_DEAD_REPLY => f.pad("BR_DEAD_REPLY"),
> BR_FROZEN_REPLY => f.pad("BR_FROZEN_REPLY"),
> BR_TRANSACTION_PENDING_FROZEN => f.pad("BR_TRANSACTION_PENDING_FROZEN"),
> BR_TRANSACTION_COMPLETE => f.pad("BR_TRANSACTION_COMPLETE"),
> - _ => f
> - .debug_struct("BinderError")
> - .field("reply", &self.reply)
> - .finish(),
> + _ => match self.source.as_ref() {
> + Some(source) => source.fmt(f),
> + None => f.pad("OTHER_ERROR"),

As sashiko points out, this is probably better as:

self.reply.fmt(f)

to just print the raw integer.

> - let reply = Err(BR_FAILED_REPLY);
> - orig.from.deliver_reply(reply, &orig);
> +
> + let param = err.source.as_ref().map_or(0, |e| e.to_errno());
> + let ee = ExtendedError::new(orig.debug_id as u32, err.reply, param);
> + orig.from
> + .deliver_reply(Err(BR_FAILED_REPLY), &orig, Some(ee));

As sashiko points out it should be info.debug_id instead of
orig.debug_id here.

Alice