ANDROID: rust_binder: don't use default implementations

Our Rust compiler currently generates incorrect CFI tags when using
dynamic calls to default implementations. So stop using default
implementations in traits until that it is fixed.

Bug: 335105888
Change-Id: I128f4b991a76714ab0f961f0484f74821851fe40
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
This commit is contained in:
Alice Ryhl 2024-04-16 07:56:04 +00:00
parent bee37573f9
commit 741b6ae073
3 changed files with 20 additions and 17 deletions

View File

@ -482,6 +482,9 @@ impl DeliverToRead for Node {
Ok(true) Ok(true)
} }
fn cancel(self: DArc<Self>) {}
fn on_thread_selected(&self, _thread: &Thread) {}
fn should_sync_wakeup(&self) -> bool { fn should_sync_wakeup(&self) -> bool {
false false
} }
@ -840,6 +843,9 @@ impl DeliverToRead for NodeDeath {
Ok(cmd != BR_DEAD_BINDER) Ok(cmd != BR_DEAD_BINDER)
} }
fn cancel(self: DArc<Self>) {}
fn on_thread_selected(&self, _thread: &Thread) {}
fn should_sync_wakeup(&self) -> bool { fn should_sync_wakeup(&self) -> bool {
false false
} }

View File

@ -64,11 +64,11 @@ trait DeliverToRead: ListArcSafe + Send + Sync {
/// Cancels the given work item. This is called instead of [`DeliverToRead::do_work`] when work /// Cancels the given work item. This is called instead of [`DeliverToRead::do_work`] when work
/// won't be delivered. /// won't be delivered.
fn cancel(self: DArc<Self>) {} fn cancel(self: DArc<Self>);
/// Called when a work item is delivered directly to a specific thread, rather than to the /// Called when a work item is delivered directly to a specific thread, rather than to the
/// process work list. /// process work list.
fn on_thread_selected(&self, _thread: &thread::Thread) {} fn on_thread_selected(&self, _thread: &thread::Thread);
/// Should we use `wake_up_interruptible_sync` or `wake_up_interruptible` when scheduling this /// Should we use `wake_up_interruptible_sync` or `wake_up_interruptible` when scheduling this
/// work item? /// work item?
@ -76,11 +76,6 @@ trait DeliverToRead: ListArcSafe + Send + Sync {
/// Generally only set to true for non-oneway transactions. /// Generally only set to true for non-oneway transactions.
fn should_sync_wakeup(&self) -> bool; fn should_sync_wakeup(&self) -> bool;
/// Get the debug name of this type.
fn debug_name(&self) -> &'static str {
core::any::type_name::<Self>()
}
fn debug_print(&self, m: &mut SeqFile, prefix: &str, transaction_prefix: &str) -> Result<()>; fn debug_print(&self, m: &mut SeqFile, prefix: &str, transaction_prefix: &str) -> Result<()>;
} }
@ -176,6 +171,9 @@ impl DeliverToRead for DeliverCode {
Ok(true) Ok(true)
} }
fn cancel(self: DArc<Self>) {}
fn on_thread_selected(&self, _thread: &thread::Thread) {}
fn should_sync_wakeup(&self) -> bool { fn should_sync_wakeup(&self) -> bool {
false false
} }

View File

@ -1475,17 +1475,13 @@ impl Thread {
let initial_len = writer.len(); let initial_len = writer.len();
while writer.len() >= size_of::<bindings::binder_transaction_data_secctx>() + 4 { while writer.len() >= size_of::<bindings::binder_transaction_data_secctx>() + 4 {
match getter(self, wait && initial_len == writer.len()) { match getter(self, wait && initial_len == writer.len()) {
Ok(Some(work)) => { Ok(Some(work)) => match work.into_arc().do_work(self, &mut writer) {
let work_ty = work.debug_name();
match work.into_arc().do_work(self, &mut writer) {
Ok(true) => {} Ok(true) => {}
Ok(false) => break, Ok(false) => break,
Err(err) => { Err(err) => {
pr_warn!("Failure inside do_work of type {}.", work_ty);
return Err(err); return Err(err);
} }
} },
}
Ok(None) => { Ok(None) => {
break; break;
} }
@ -1634,6 +1630,9 @@ impl DeliverToRead for ThreadError {
Ok(true) Ok(true)
} }
fn cancel(self: DArc<Self>) {}
fn on_thread_selected(&self, _thread: &Thread) {}
fn should_sync_wakeup(&self) -> bool { fn should_sync_wakeup(&self) -> bool {
false false
} }