From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.70 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795950477; b=WIZW2tfv0U5KeQuV7JP2ywYH2xqAHkMiyOvU36sPbCdAKLfAvz/Bl6aAdVFSJwudMU7B +d2VA6qXixdvzyoBd2v8/PfSHefc8cphFdbvy7i4Qe4S4ejWGMovk3MDUBYznQ8XRxGb8 kuYHlpKGecIwWywk3j7vEPO0mBCV+YMW8dmS82C3jecMWPCR1t+tXRyfor5/6PLGcP0qt j7AdH0oVVE/rxqFcKSSCzSSPuMMqN2tVGDo8b7GoS1VbMb/KgbG4t14NNMEeRnXfAHlmE xsH8/avWdN1ws+1Xmo1FnTI9ybJYTb0ARpa6G37f791woVwoQ1YGzrNNjwueFEOi4jg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795950477; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:X-Mailer:Message-ID:Subject:From:To:Cc: Content-Type; bh=gLgP+fbqxEtj4MEtrRZSo3YCeb0X1FqbioRz/ZlnQ24=; b=ihstMErrqRseoL1NjDNyauFW16YucOlcpkox1yMN3jCq+VaKHs2CtyzmbUzdGeIJDqC/ ZUG8oLjPrsJG9IEUUqFdkgoQCwACJ1ys7xbJX22zwM7/lqa4wOQojxmvPaGOxOTKsiWn9 6HKpokslD5q798r9Ie3bpwajQlqVGjy9FOs/FiAczz2WcUF48/Q1pWs6B48EPY/kd4emk M62VumYOP8kHMowgx2djHHdg03f5n0oHpOTs7LTUw9ovQ7h/Zn6NF5Gaesji+HDYQDvPN jL2hxB7de8mGRbBtvU0vMWJF3nOH/8POCpIp/L6XNVlHF4Kcc74Swf6pfFG7mHUF0UQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=gsvjcvSo; arc=none smtp.remote-ip=209.85.221.70 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7BDF606A31C for ; Sun, 29 Nov 2026 11:07:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A7BDF606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=gsvjcvSo Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-4ab855a8c21so7425871f8f.1 for ; Sun, 29 Nov 2026 03:07:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1795950475; x=1796555275; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=gLgP+fbqxEtj4MEtrRZSo3YCeb0X1FqbioRz/ZlnQ24=; b=gsvjcvSo31d3pPRI1Ha8ZrPapr9AWa1UnCgZVCufLhvHaJmZiGyXdHXaIL+42NPG7G trC0nBgDq/bKabSM/TeHijEOBraVRqy71B1M/08D18+gLtoaggxO3ZMtI8DLcF2LVs8w klsS55PM/HG2O4JlOddRm0Vs3tSIGAI1KNaePDnXEO9NjqXAoQPnD/9fB8ETvMtaoWRK GNm++k35rNHku2JtIR6F+EnCFJvmGLbAJKwe2RLlZYX5hwSPY9NKRqfACkOzirSgidxE cmSSiHCDfaJkN/ZMDCQP2HGF+dD8w2S+bq++6JTbX1g/xu6nkpT9tsVwgKo8L5mvxZ2F qtDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795950475; x=1796555275; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gLgP+fbqxEtj4MEtrRZSo3YCeb0X1FqbioRz/ZlnQ24=; b=F5F5xTkpP99sYKN5U32HKUinrkQ5UwdpF1o2tkzZYrqRTyKk9WGNm4ub/MUFpC7UC6 wQZndE64xVLet1Fby8FMrBwfjWbutuQrl7rP/xJ6fnuqSUo1cvbvTtS+0FZ/49r3ELwL Ulh08pasI/ipcdZhR+rS3/MP632DkbESsrbrspnWO96n0J23LJpp/XR+o7xFrzWnP/qw lbdLn9C68mM3Vw8mFdDVW3HTeYhKWutmsz1poDnNr47wCvBDtLSWV1r3S1dtQrf2bbEv 8/WCGL0Wj8clAtD7lhuBOVK647tUB4y3X/12WAQSvIsT0/O/8nwsB8fFqEDJ0OWpjOcJ oh9w== X-Forwarded-Encrypted: i=1; AL+hErG7xjQDO581hf7SVOPDVuiMFzWPM/MahqiGotefVTD6nyk8JPRVvjsdg8TVKYijQRDJzy5kSmautkV6bx4vIw==@vger.kernel.org X-Gm-Message-State: APuU4Z8UZL/TOIp5qpl9ZikzLnDTOWv7FV3/HBV+T7pI/Qbe5S467V/W GcQz41Q92iGTdB447TSytlX7w3cSAp0/lH4sDFL79qBiFQqGylMAJPvx49baLE7nScwryM+GuTJ 09fcelOqCUuFi/74R2Q== X-Received: from wrmk14.prod.google.com ([2002:adf:e3ce:0:b0:4a5:efa0:b476]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6000:4b1e:b0:49f:800e:aefc with SMTP id ffacd0b85a97d-4abb1baaa33mr57886174f8f.14.1795950474751; Sun, 29 Nov 2026 03:07:54 -0800 (PST) Date: Sun, 29 Nov 2026 11:07:53 +0000 In-Reply-To: <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 References: <20261128175631.27887-1-adhyanshverma2010@gmail.com> <20261128194924.53915-1-adhyanshverma2010@gmail.com> X-Mailer: git-send-email 2.56.1.839.g22a8290db9-goog Message-ID: <20261129110753.1133472-1-aliceryhl@google.com> Subject: Re: [PATCH v3] rust_binder: unfreeze process before returning on allocation failure From: Alice Ryhl To: Adhyansh Verma Cc: Alice Ryhl , Carlos Llamas , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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 I don't think we should take this patch. If we can't allocate and send the freeze notifications, then we haven't properly unfrozen the process either -- unfreezing before prepare_freeze_messages() would leave the process unfrozen while freeze listeners still think it is frozen. Keeping the allocation before setting is_frozen = IsFrozen::No is intentional and symmetric with the freeze path (which rolls back is_frozen = IsFrozen::No if prepare_freeze_messages() returns ENOMEM): on ENOMEM the ioctl fails cleanly without leaving state half-updated, and userspace can retry. Alice