rust_binder: Implement BINDER_DEBUG_DEATH_NOTIFICATION

This adds dynamic debug logs for:
- Memory allocation (OOM) failures when requesting
  death notifications
- Registration and cancellation lifecycle events
  (BC_REQUEST / BC_CLEAR)
- Delivery of death notification events to userspace
  (BR_DEAD_BINDER)

Reviewed-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Jahnavi MN <jahnavimn@google.com>
Link: https://patch.msgid.link/20260716-rust_binder_debug_mask-v4-6-3d7436c2d2f2@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jahnavi MN 2026-07-16 08:37:48 +00:00 committed by Greg Kroah-Hartman
parent c61f3ad221
commit 7ddb9f5d45
2 changed files with 19 additions and 0 deletions

View File

@ -1107,6 +1107,11 @@ fn do_work(
// We're still holding the inner lock, so it cannot be aborted while we insert it into
// the delivered list.
process_inner.death_delivered(self.clone());
binder_debug!(
DeathNotification,
"sending death notification, cookie {:016x}",
cookie
);
BR_DEAD_BINDER
};

View File

@ -1253,6 +1253,10 @@ pub(crate) fn request_death(
// Queue BR_ERROR if we can't allocate memory for the death notification.
let death = UniqueArc::new_uninit(GFP_KERNEL).inspect_err(|_| {
thread.push_return_work(BR_ERROR);
binder_debug!(
DeathNotification,
"BC_REQUEST_DEATH_NOTIFICATION failed due to memory allocation failure"
);
})?;
let mut refs = self.node_refs.lock();
let Some(info) = refs.by_handle.get_mut(&handle) else {
@ -1296,6 +1300,11 @@ pub(crate) fn request_death(
info.node_ref().node.add_death(death, &mut owner_inner);
}
}
binder_debug!(
DeathNotification,
"BC_REQUEST_DEATH_NOTIFICATION handle {handle} cookie {:016x}",
cookie
);
Ok(())
}
@ -1339,6 +1348,11 @@ pub(crate) fn clear_death(&self, reader: &mut UserSliceReader, thread: &Thread)
}
}
binder_debug!(
DeathNotification,
"BC_CLEAR_DEATH_NOTIFICATION handle {handle} cookie {:016x}",
cookie
);
Ok(())
}