Commit 892df033 authored by Wedson Almeida Filho's avatar Wedson Almeida Filho Committed by Alice Ryhl
Browse files

ANDROID: rust_binder: add death notifications

This adds death notifications that let one process be notified when
another process dies.

A process can request to be notified when a process dies using
`BC_REQUEST_DEATH_NOTIFICATION`. This will make the driver send a
`BR_DEAD_BINDER` to userspace when the process dies (or immediately if
it is already dead). Userspace is supposed to respond with
`BC_DEAD_BINDER_DONE` once it has processed the notification.

Userspace can unregister from death notifications using the
`BC_CLEAR_DEATH_NOTIFICATION` command. In this case, the kernel will
respond with `BR_CLEAR_DEATH_NOTIFICATION_DONE` once the notification
has been removed. Note that if the remote process dies before the kernel
has responded with `BR_CLEAR_DEATH_NOTIFICATION_DONE`, then the kernel
will still send a `BR_DEAD_BINDER`, which userspace must be able to
process. In this case, the kernel will wait for the
`BC_DEAD_BINDER_DONE` command before it sends
`BR_CLEAR_DEATH_NOTIFICATION_DONE`.

Note that even if the kernel sends a `BR_DEAD_BINDER`, this does not
remove the death notification. Userspace must still remove it manually
using `BC_CLEAR_DEATH_NOTIFICATION`.

If a process uses `BC_RELEASE` to destroy its last refcount on a node
that has an active death registration, then the death registration is
immediately deleted. However, userspace is not supposed to delete a
node reference without first deregistering death notifications, so this
codepath is not executed under normal circumstances.

Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-10-08ba9197f637@google.com/


Change-Id: I0ceb3b7ea507470be2499d8c1fea2e960b647519
Co-developed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Signed-off-by: default avatarWedson Almeida Filho <wedsonaf@gmail.com>
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
Bug: 278052745
parent fe5dea5f
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment