From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Adhyansh Verma <adhyanshverma2010@gmail.com>
Cc: Alice Ryhl <aliceryhl@google.com>,
Carlos Llamas <cmllamas@google.com>,
rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v3] rust_binder: unfreeze process before returning on allocation failure
Date: Sun, 29 Nov 2026 13:25:32 +0100 [thread overview]
Message-ID: <2026112904-swimming-error-d7d2@gregkh> (raw)
In-Reply-To: <20261128194924.53915-1-adhyanshverma2010@gmail.com>
On Sun, Nov 29, 2026 at 01:19:24AM +0530, Adhyansh Verma wrote:
> 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. Furthermore, preparing messages
> with GFP_KERNEL before clearing is_frozen leaves a window where
> concurrent operations observe stale IsFrozen::Yes, failing early in
> top-level ioctl_freeze() leaves other binder contexts of the process
> frozen, and dropping unfreeze notifications on allocation failure leaves
> freeze listeners out of sync.
>
> Unfreezing the process itself is a zero-allocation operation and must
> succeed so that incoming transactions are not blocked.
>
> Update ioctl_freeze() to:
> - Reset inner.is_frozen = IsFrozen::No, inner.sync_recv = false, and
> inner.async_recv = false under lock before calling
> prepare_freeze_messages(), avoiding race windows with concurrent
> operations.
> - Maintain a freeze_version counter on ProcessInner incremented on every
> is_frozen transition, allowing FreezeListener instances to detect state
> changes and avoid suppressing notifications even if an intermediate
> notification could not be allocated due to OOM.
> - Continue unfreezing all matching process contexts in top-level
> ioctl_freeze() even if message preparation on one context fails.
> - Return Err(ENOMEM) after ensuring processes have been unfrozen if
> prepare_freeze_messages() fails.
>
> Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver")
> Signed-off-by: Adhyansh Verma <adhyanshverma2010@gmail.com>
> ---
> v2 -> v3:
> - Add freeze_version counter to ProcessInner and track last_freeze_version
> on FreezeListener so that listeners detect state transitions even if
> unfreeze notification allocation fails under OOM
> v1 -> v2:
> - Clear inner.is_frozen, sync_recv, and async_recv under lock before
> calling prepare_freeze_messages() to prevent concurrent callers from
> observing stale IsFrozen::Yes state
> - Iterate through all matching process contexts in top-level
> ioctl_freeze() during unfreeze, ensuring all contexts are unfrozen even
> if one hits an allocation error
Please slow down. Worst case, wait 24 hours between patches. There is
no rush here.
thanks,
greg k-h
next prev parent reply other threads:[~2026-11-29 12:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2026-11-29 13:54 ` Adhyansh Verma
2026-11-29 14:05 ` Miguel Ojeda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2026112904-swimming-error-d7d2@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=adhyanshverma2010@gmail.com \
--cc=aliceryhl@google.com \
--cc=cmllamas@google.com \
--cc=rust-for-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox