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:Alice Ryhl <aliceryhl@google.com> Signed-off-by:
Wedson Almeida Filho <wedsonaf@gmail.com> Signed-off-by:
Alice Ryhl <aliceryhl@google.com> Bug: 278052745
Loading
Please sign in to comment