Skip to content

Commit 6849cab

Browse files
iganschel-bitgregkh
authored andcommitted
rust_binder: reject context manager self-transaction
Rust binder resolved handle 0 to the context manager node, but it does not reject the case where the caller owns the same node. The C binder driver rejects transactions from the context-manager process to handle 0 after resolving the target node. Match that behavior in Rust Binder by rejecting handle 0 transactions when the resolved context-manager node is owned by the calling process. This applies to both synchronous and oneway transactions because both paths resolve the target through Process::get_transaction_node(). Cc: stable <stable@kernel.org> Fixes: eafedbc ("rust_binder: add Rust Binder driver") Signed-off-by: Keshav Verma <iganschel@gmail.com> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260625103957.730-1-iganschel@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 803c8a9 commit 6849cab

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/android/binder/process.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,11 @@ impl Process {
900900
pub(crate) fn get_transaction_node(&self, handle: u32) -> BinderResult<NodeRef> {
901901
// When handle is zero, try to get the context manager.
902902
if handle == 0 {
903-
Ok(self.ctx.get_manager_node(true)?)
903+
let node_ref = self.ctx.get_manager_node(true)?;
904+
if core::ptr::eq(self, &*node_ref.node.owner) {
905+
return Err(EINVAL.into());
906+
}
907+
Ok(node_ref)
904908
} else {
905909
Ok(self.get_node_from_handle(handle, true)?)
906910
}

0 commit comments

Comments
 (0)