Rust for Linux List
 help / color / mirror / Atom feed
* [PATCH] rust_binder: unfreeze process before returning on allocation failure
@ 2026-11-28 15:44 Adhyansh Verma
  2026-11-28 17:56 ` [PATCH v2] " Adhyansh Verma
  0 siblings, 1 reply; 7+ messages in thread
From: Adhyansh Verma @ 2026-11-28 15:44 UTC (permalink / raw)
  To: Alice Ryhl; +Cc: Carlos Llamas, Greg Kroah-Hartman, rust-for-linux

In Process::ioctl_freeze(), when info.enable == 0 (unfreeze request),
the driver calls self.prepare_freeze_messages()? before acquiring
self.inner.lock() to reset inner.is_frozen = IsFrozen::No.

If prepare_freeze_messages() fails due to memory allocation failure
(AllocError), the ? operator immediately returns Err(ENOMEM).
Consequently, inner.is_frozen is never updated to IsFrozen::No, leaving
the target process permanently frozen.

Unfreezing the process itself is a zero-allocation operation and must
succeed so that incoming transactions are not blocked. In C Binder
(binder_ioctl_freeze), unfreezing a process never fails.

Update ioctl_freeze() to reset inner.is_frozen = IsFrozen::No regardless
of whether notification message allocation succeeds. If
prepare_freeze_messages() fails, return Err(ENOMEM) after ensuring the
process has been unfrozen.

Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
Signed-off-by: Adhyansh Verma <adhyanshverma2010@gmail.com>
---
 drivers/android/binder/process.rs | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs
index 1f4cb43f1de..e4d5be79d9f 100644
--- a/drivers/android/binder/process.rs
+++ b/drivers/android/binder/process.rs
@@ -1536,14 +1536,19 @@ pub(crate) fn drop_outstanding_txn(&self) {
     #[export_name = "rust_binder_freeze"]
     pub(crate) fn ioctl_freeze(&self, info: &BinderFreezeInfo) -> Result {
         if info.enable == 0 {
-            let msgs = self.prepare_freeze_messages()?;
+            let msgs = self.prepare_freeze_messages();
             let mut inner = self.inner.lock();
             inner.sync_recv = false;
             inner.async_recv = false;
             inner.is_frozen = IsFrozen::No;
             drop(inner);
-            msgs.send_messages();
-            return Ok(());
+            return match msgs {
+                Ok(msgs) => {
+                    msgs.send_messages();
+                    Ok(())
+                }
+                Err(kernel::alloc::AllocError) => Err(ENOMEM),
+            };
         }
 
         let mut inner = self.inner.lock();
-- 
2.56.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-11-29 14:05 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-28 15:44 [PATCH] rust_binder: unfreeze process before returning on allocation failure Adhyansh Verma
2026-11-28 17:56 ` [PATCH v2] " Adhyansh Verma
2026-11-28 19:49   ` [PATCH v3] " Adhyansh Verma
2026-11-29 11:07     ` Alice Ryhl
2026-11-29 12:25     ` Greg Kroah-Hartman
2026-11-29 13:54       ` Adhyansh Verma
2026-11-29 14:05         ` Miguel Ojeda

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox