From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795955137; b=eP1sMh8z6Lk6Lnai58f3UNifGyenU9OzzqeUcuSQtG1VdzsM/+fHxZGBG/oskPQ0Jw7D D84cNNKAcy3CHHA9x2Ez27WhDCx98iu1EebopjXE46uojqYV+fFXYPZdTCE+i4jz4n0E7 bHhBXUB0siUFG83ND0EU+sUeQb80gn8gIdkhTnyOz6l/5Be2lQ7DXZ5yGjlTZBoq5IYw4 +PGbHM2JwmCac4LeoD7zpUByhNjwlrsX6EZ6DkbscbuxGU0wXvFTnIgJCCezcdNVa3Qc2 V+ozSprhRGaeEW5mkMTI4Hs3Mw/IHlbrENORrQiTnruQ2ETE99RH+9fbB5dLN696dgA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795955137; h=Received:DKIM-Signature:Date:From:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=ZPsmJeBTx/fzbl/Atn8bt3/Bgljk+6XLDQ0HUxNUGXw=; b=QeJTWPLRIUyIZ+NExjDXsgDrBfu/wFRlSGPV3pfNEcqHRuQXRE/FTeV5wKIUB2aN59By NFJ6uoi74k4N6V8BKnL+Z0fDdFeXWIiPBNFHd+rbdzlZ9fZjHAkvRsPqbkv835I2QbiM1 MLJ7UwBhOzVkwzAjpvOasoF6XVEM8B0/RIczJtvPaRdBDK2cBbp1L1VYQXRQDSpaEHfXk AeYfmJxBNc9YH9BcPu1xh89/ihKrgnRq41unm7ibRzXjA2Qun4IcIwggCffkcTgDClKz1 Nrk8qaJzy0O15EEV4HF5j30Qkhd9ChYwGNtuyN5Dz5q2Ke0JFeCwV1JoBI/zD+lS9zQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CvYX6DG3; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 95D6F606A323 for ; Sun, 29 Nov 2026 12:25:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CvYX6DG3 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 415971F00896; Sun, 29 Nov 2026 12:25:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795955137; bh=ZPsmJeBTx/fzbl/Atn8bt3/Bgljk+6XLDQ0HUxNUGXw=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=CvYX6DG33dxq5vsl4F5KWRS3L7s9aNMhSD+h7v4lZ4V8VfJchqI9iPpTTSrtj71z5 jBYBSCrhmmT341qCsusASlqSMGmppEWu4Kw0pKQSgDphrc6JSVUe2w585wQGAAuTet MlpienJoS2Jds9i1WVRh72mSxTDXBhTmwV1pprOE= Date: Sun, 29 Nov 2026 13:25:32 +0100 From: Greg Kroah-Hartman To: Adhyansh Verma Cc: Alice Ryhl , Carlos Llamas , rust-for-linux@vger.kernel.org Subject: Re: [PATCH v3] rust_binder: unfreeze process before returning on allocation failure Message-ID: <2026112904-swimming-error-d7d2@gregkh> References: <20261128175631.27887-1-adhyanshverma2010@gmail.com> <20261128194924.53915-1-adhyanshverma2010@gmail.com> X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > --- > 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