Skip to contentSkip to conversation

rust_binder: report EINVAL for unknown handles

PATCH In review Alice Ryhl 2 participants 2 messages Nov 18 – Nov 21

Subsystems (3)
lore
Share & tools
lore

Alice Ryhl

author maintainer
#0 lore raw

PATCH 1/1 rust_binder: report EINVAL for unknown handles

Currently unknown handles are reported as ENOENT, which userspace doesn't treat as a fatal error. However, providing the wrong handle is a fatal API violation, and indicates UAF in the userspace process.

Thus, change it to EINVAL to match C Binder and make userspace treat it as a fatal error.

Fixes eafedbc7c050 ("rust_binder: add Rust Binder driver")
---
 drivers/android/binder/process.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder/process.rs +1 -1
index e97213250beb..406d80cfff08 100644
@@ -958,7 +958,7 @@ pub(crate) fn get_node_from_handle(&self, handle: u32, strong: bool) -> Result<N
             .lock()
             .by_handle
             .get_mut(&handle)
-            .ok_or(ENOENT)?
+            .ok_or(EINVAL)?
             .node_ref()
             .clone(strong)
     }

---
base-commit: 917fcbf033154a6c8d83cfa6c88f012b71eb37b2
change-id: 20261029-binder-unknown-einval-10407d1ebb1e

Best regards,

Signature · 1 line
Alice Ryhl <[email protected]>
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines · Alice Ryhl

Currently unknown handles are reported as ENOENT, which userspace doesn't treat as a fatal error. However, providing the wrong handle is a fatal API violation, and indicates UAF in the userspace process.

Thus, change it to EINVAL to match C Binder and make userspace treat it as a fatal error.

Fixes eafedbc7c050 ("rust_binder: add Rust Binder driver")
---
 drivers/android/binder/process.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/android/binder/process.rs +1 -2
index e97213250beb..406d80cfff08 100644
@@ -958,7 +958,7 @@ pub(crate) fn get_node_from_handle(&self, handle: u32, strong: bool) -> Result<N
             .lock()
             .by_handle
             .get_mut(&handle)
-            .ok_or(ENOENT)?
+            .ok_or(EINVAL)?
             .node_ref()
             .clone(strong)
     }
 
---

base-commit: 917fcbf033154a6c8d83cfa6c88f012b71eb37b2
change-id: 20261029-binder-unknown-einval-10407d1ebb1e

Quoted 4 lines

Best regards,

Signature · 1 line
Alice Ryhl <[email protected]>

LGTM,