From nobody Fri Apr 3 06:29:39 2026 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C4A8C30F553 for ; Wed, 18 Feb 2026 11:53:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771415629; cv=none; b=jCaS8ek8FNhp4v89pRnZ2eI7YbzsOndr1qrfcnCe6SluUOvoGUz1abe7XFvm1tRUSjJx4DOxtdRCnL4tDNShi0ZfwptlMqE4isTc+PF6CNBVqEyC9zvwEIPZh2X2V1c+qpDRvG2me7sky3oZ0tS4bZYPEzX9/0n1spD5e9uSEgc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771415629; c=relaxed/simple; bh=dxslJAb5KIt29+Pmlra1MsYzJUsqBlgsseUHaKRC00Q=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pIdNH5Rm/jb/uLpBtcu52dKAAgC2mht20eirHr1Iv9OpTuaRE/9jmV48troVwDSd0aC03JOEBh3fLlvWWXvstUro17yUjavIlqGPe9Xg6cXU+G9rjryjxv6+7acU5A3sx+nni/vymeAuxoii/MWQ2t9CngqwuUdv3Oi/eF2HmLk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=IKsVbLsP; arc=none smtp.client-ip=209.85.128.74 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.b="IKsVbLsP" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-4836bf1a920so60150545e9.3 for ; Wed, 18 Feb 2026 03:53:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1771415626; x=1772020426; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2nREefhNbsS6m+NzCv8p/u3MUoT+tS1ddYgBqAgzIBg=; b=IKsVbLsP2kRnSGVyZ7gFXiqkELJYXkM4Y9t/+2Z83IeHfKMt8akYguBhpAgWP9z31C 984VJZaCffFLZL5SvUWqH8nDeJxnRrb2+CKYfIrfHgkxx1E9Nd45yOlmDcWdGJhUMMzV caVi8lE//nApGsh6oAmSuE9RoettuU9SibY3qX+lDc3LmtF/Y9kEbAFJnIAj2QppTMBp lFQlVSbDCnMjTgqynDEIj5l7f0Ta5eg7yXFYQ7YpsUlmFAd0Zl2O4s7cm+9NatfuZBNE 6XcqFG1Pc+lqNNNG3XfZs5zALj12Jdc2SHDS08scgRMDAmDbKK22jhsMkRJmw5cag4uK lK6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771415626; x=1772020426; h=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; bh=2nREefhNbsS6m+NzCv8p/u3MUoT+tS1ddYgBqAgzIBg=; b=KRO+YuMobICYgjXR9qlSa6BRMFNS4VM0Rcp4e6O6v8dMLw39OFLQQkVLasxbXMsV7m GtL0g8SY4mcW5uSOeN35L3ZMqDErA46sYu47+kodGHKXKQHb0KynAooUjBcLvmRPfYUI hVTLJ+Ht5HwUnjfmwQcsGpbakiRS+qEpEXM/vSSf7rzflfrM7WzDBGj4j73AQc4oBSD7 o0UQuw5AdesrgU8U8Hv9OpVvggzf5/MzSlclN3OkSMoaUnsQbec7jseFk1LfwrnzSNiV 6EPDxaohFi5J/uY6+TNgi6tlDsDPPn6bSBxBPzokLW6Ls1I8laMCrAKtu+o7e5AlfkHT 3buA== X-Forwarded-Encrypted: i=1; AJvYcCVcRlT0X53nlUbAE0n3pix8g+vO3+P6fzyeOKAJeoEE8JeMkfyZZnxfcalK8Wv7RJ+b8HEu5jVT6si7/74=@vger.kernel.org X-Gm-Message-State: AOJu0Ywr+clzAvChxoM5mi0wp6lZScvp4O1bII7QxGUNYWsJrdxnbKyA wVojizTO8Rqe1sDrP/Y9z+zwmCYSLr+V83TXY6V++l5RNzWv1ESfHuFc9mqvziLb2uoVi0b+Zsy aRTaFplD1ihuFO257Jg== X-Received: from wmof9.prod.google.com ([2002:a05:600c:44c9:b0:477:988a:7675]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1c25:b0:47d:3ead:7440 with SMTP id 5b1f17b1804b1-48379c14606mr212400745e9.32.1771415625987; Wed, 18 Feb 2026 03:53:45 -0800 (PST) Date: Wed, 18 Feb 2026 11:53:27 +0000 In-Reply-To: <20260218-binder-vma-check-v2-0-60f9d695a990@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260218-binder-vma-check-v2-0-60f9d695a990@google.com> X-Developer-Key: i=aliceryhl@google.com; a=openpgp; fpr=49F6C1FAA74960F43A5B86A1EE7A392FDE96209F X-Developer-Signature: v=1; a=openpgp-sha256; l=2898; i=aliceryhl@google.com; h=from:subject:message-id; bh=dxslJAb5KIt29+Pmlra1MsYzJUsqBlgsseUHaKRC00Q=; b=owEBbQKS/ZANAwAKAQRYvu5YxjlGAcsmYgBplahFqqe27pmaRIiimlvXAoI7c4Aaeb8gzBCoW 7sqLygMmP2JAjMEAAEKAB0WIQSDkqKUTWQHCvFIvbIEWL7uWMY5RgUCaZWoRQAKCRAEWL7uWMY5 RiinD/93Hu+5kQo1qJcL+IetJ2vxyhhemT1hfThuvAADi5VceWTgLmJNepFXO7G77pW/2GeTBB3 hglYyOoUtJStG2fdTUp+EutcYerAtSgpAnbhEpOIaMKO2Yes5W+M92MyD+6fyb2jpTNX29pujW0 uca1oss6kBre/m26qiICetpHoL1NS1gN7YdP9JmrVujhz3kE+tFIJlMb+hNWp6ai7tdcn4gTSB9 J9OLQvOEIMk/kiA0xLkm+5Gl/u+m5OBPNotZfvsSwjCFDHFAi76dii3zfnn0ogXbsk8Cng5gEkS CK49G2PrS5MB/lyNm8FVpbgDxUbHE4/HJ7qOJv7iBgDtBwkxpeW+4sWHaflHwSkyBMB0o06XkSy CcTe+B3ydUvhCe1jg0tUlmuCqtsRcBwEX4XonP13fIL3aJPniOO4Ofg5aT1emcncDjlovMuwzj6 ChcMKSLOqtG2QV6h2HY6a7qu7ih04BkCqiTbRiQ3zKOKqB29seNh/1VwxImeQ3abXclaS/J87Xd uEk0oq0T080GYz/oSMJjJ9jLLpuinmaE6Y6d5KtexouBUr1Z2YA40lB77+roEZf/5v/XL+n/rVc Yc/ENTdwPvpAqKsnqxruyi+lhem8Kr5FlqNy93Krvh7d4uqyPNFvWixXuiZrM0Rb+RVZDF1DJ1I F2yQblZRdRGtoHQ== X-Mailer: b4 0.14.2 Message-ID: <20260218-binder-vma-check-v2-2-60f9d695a990@google.com> Subject: [PATCH v2 2/2] rust_binder: avoid reading the written value in offsets array From: Alice Ryhl To: Greg Kroah-Hartman , Carlos Llamas , Jann Horn Cc: Miguel Ojeda , Boqun Feng , Gary Guo , "=?utf-8?q?Bj=C3=B6rn_Roy_Baron?=" , Benno Lossin , Andreas Hindborg , Trevor Gross , Danilo Krummrich , Lorenzo Stoakes , "Liam R. Howlett" , linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-mm@kvack.org, Alice Ryhl , stable@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable When sending a transaction, its offsets array is first copied into the target proc's vma, and then the values are read back from there. This is normally fine because the vma is a read-only mapping, so the target process cannot change the value under us. However, if the target process somehow gains the ability to write to its own vma, it could change the offset before it's read back, causing the kernel to misinterpret what the sender meant. If the sender happens to send a payload with a specific shape, this could in the worst case lead to the receiver being able to privilege escalate into the sender. The intent is that gaining the ability to change the read-only vma of your own process should not be exploitable, so remove this TOCTOU read even though it's unexploitable without another Binder bug. Cc: stable@vger.kernel.org Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver") Reported-by: Jann Horn Reviewed-by: Jann Horn Signed-off-by: Alice Ryhl Acked-by: Liam R. Howlett --- drivers/android/binder/thread.rs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/android/binder/thread.rs b/drivers/android/binder/thre= ad.rs index 1f1709a6a77abc1c865cc9387e7ba7493448c71d..a81910f4cedf9bf485bf1cf954b= 95aee6c122cfd 100644 --- a/drivers/android/binder/thread.rs +++ b/drivers/android/binder/thread.rs @@ -1016,12 +1016,9 @@ pub(crate) fn copy_transaction_data( =20 // Copy offsets if there are any. if offsets_size > 0 { - { - let mut reader =3D - UserSlice::new(UserPtr::from_addr(trd_data_ptr.offsets= as _), offsets_size) - .reader(); - alloc.copy_into(&mut reader, aligned_data_size, offsets_si= ze)?; - } + let mut offsets_reader =3D + UserSlice::new(UserPtr::from_addr(trd_data_ptr.offsets as = _), offsets_size) + .reader(); =20 let offsets_start =3D aligned_data_size; let offsets_end =3D aligned_data_size + offsets_size; @@ -1042,11 +1039,9 @@ pub(crate) fn copy_transaction_data( .step_by(size_of::()) .enumerate() { - let offset: usize =3D view - .alloc - .read::(index_offset)? - .try_into() - .map_err(|_| EINVAL)?; + let offset =3D offsets_reader.read::()?; + view.alloc.write(index_offset, &offset)?; + let offset: usize =3D offset.try_into().map_err(|_| EINVAL= )?; =20 if offset < end_of_previous_object || !is_aligned(offset, = size_of::()) { pr_warn!("Got transaction with invalid offset."); --=20 2.53.0.310.g728cabbaf7-goog