From nobody Mon Jun 8 14:35:35 2026 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 EE9B234EF07 for ; Fri, 29 May 2026 01:19:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780017574; cv=none; b=LJEEqGF9ysZF8Q2cDKUgmkbU3arsJLAQ5lDUD4xtIizRjyz+Z24uWOBFuCNnyVINCW7JvLlEI6pmecFL4wKQd3DkLk4z3KMuTXu2xyGdoBhmuXfXoEl0hCZgEhnF2Bh0iqqmK186/PxT8oi8omthDweb8hpy1FAuvd4PO8fmtcw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780017574; c=relaxed/simple; bh=9+5tF0J6/VIAoz29m+zdLF6hSRtmeSnELRVfUP1Q47c=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=V1bplOV8yQANd1Vou0e87w47EZru8NhBdwrSb/euzYZy/okvkviyWPEHRCQJBVVeM74GaKHtcw1jEK8GUGdzMxKEzx7VuNQCzZreUpuTaW+t6F/UKD4AgTfmsSvxc7LwEA6BfEzuWczwFlj+2BdB+d+Jhry1YdjRJDgSJqMx0Qc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=h4S0loMQ; arc=none smtp.client-ip=209.85.210.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h4S0loMQ" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-82f8b60e54dso10500011b3a.2 for ; Thu, 28 May 2026 18:19:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1780017572; x=1780622372; darn=vger.kernel.org; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=qIjpzaojjPAZHKihdp6RPFa2Tfe6qCRbgRVNDw+LS2c=; b=h4S0loMQ50rxVdUCadzO/8AKEv8cRbZkXW02Xok2Adjt17yK/wQ3GrTbR1D8D0Wph0 cu4wTR2J2o2MxJb3RCQALxAUYY0BJQd7cUAzKw6msD9Pic9pVMCEpqttxchAdnNzdei6 IXhm0YNWGPsPH99ZhpEp3CMSipxgT0JWk06y1FqYfv+8UZ2l1MPfC4IO2ZF8iMiIeHKW NKvmUbTkAncAbJyy/W6N+QXQ6zaKUwOBDSYIlk+8R8bsbTgBksUIYeSmsWg66bRqn/GD hYmSbYHkMS5Rmxm4SzlM0drZRzhPqFRBs+gOI7ytDsmOa3fnLunugVGqWlDwLY234ofZ gccg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780017572; x=1780622372; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qIjpzaojjPAZHKihdp6RPFa2Tfe6qCRbgRVNDw+LS2c=; b=dmogiixM5JONmLhmE5zArISjpBgloGsqX61sZZb8TI4lo6aqr1uIV7xj/fFxaYGcIH HFXXmmMVFBaKaWNDpp81ddbQuaRTguxtdvwPOCno7SBrBr9tMx4sBY6RBrviCJoepNbg sn5ilIb0k7db7x8ftzsfP/ljFNVLSawu0ZlCLsmiPWWdahgfG59tYM9qZg8GpYn3wLWN oCUY9nV4Nwvku0gLMOucebensfvQWVB7ZlKkWgkOshA2HONcv1S51E3zeGEfrVUpb7U0 iC0eRND7xdG5AF3/qAE7jGXn9bu7XctClKaZpYA7IcaiUK/n/xSLpyPmMuU4DeuobZgF Lhuw== X-Gm-Message-State: AOJu0YznuDS+cV8zS68+wD8LEp1Bvwtp49mNBUCC1RnMVfX5/MlgJaqT crIbVUu3yjI+P7WvLOrUp88oDmBSONr8y9OBTzKqqG8S3YvVqVj4OnlWCQ3UuQ== X-Gm-Gg: Acq92OH3uw3UI+HbYeTLIKgotoNHGk7m4Kwm1PWh5o96KLAlNrWkDhfAHpV/eHly7vc EXJ4g5lIpAqwOt/joDCe7RPV2fmD9BqioL8kasiTeTofAGBLDJgK8+F8OPbt2NZnEIqZdtCCIVk 5FI0YJVskuxeGbcBVxJHH9XZVozc464/2XUEUY9K2Z8+kgSWLevbWmViUYOWtPGtUrzhTPcKsl3 WUmz05otsMNhV7CUk8dnpDqAHvMYb2Om3TKpQmTUIolGwcBjCrHE5NCHQDCcrjNkWi/enuc80nX SzkCf9Ar+2qsvsYRJzmFSp2XCvIbfksegU7nVjjzb+2vTuZNPm/d0M+ZT5c5cLklgKeMyduK7cw /KCiNdSKnXnJ/2OF7rOZ89IaqkpG0BptruNNf41uav7gJTDFpUDi2DajYZYhmAU7AhsufQ7AYmn rbB12AVmNJ+MrmA5LCOYeZC/W8IK65EW1l0BAo1F0OctjCquAxDmc1ww== X-Received: by 2002:a05:6a00:4f86:b0:83e:2c38:f5d5 with SMTP id d2e1a72fcca58-84212b81ad5mr662298b3a.28.1780017572235; Thu, 28 May 2026 18:19:32 -0700 (PDT) Received: from v4bel ([58.123.110.97]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84214cec0d9sm35920b3a.55.2026.05.28.18.19.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 May 2026 18:19:31 -0700 (PDT) Date: Fri, 29 May 2026 10:19:27 +0900 From: Hyunwoo Kim To: gregkh@linuxfoundation.org, arve@android.com, tkjos@android.com, brauner@kernel.org, cmllamas@google.com, aliceryhl@google.com, mo@sdhn.cc, wedsonaf@gmail.com, Liam.Howlett@oracle.com Cc: linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, stable@vger.kernel.org, imv4bel@gmail.com Subject: [PATCH] rust_binder: use a u64 stride when cleaning up the offsets array Message-ID: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allocation's Drop walks the offsets array (binder_size_t =3D u64 entries), cleaning up the objects, but it used usize instead of u64 for both the stride and the per-entry read. On 64-bit kernels (usize =3D=3D u64) this is harmless, but on 32-bit kernels it walks the 8-byte entries in 4-byte steps, iterating an N-entry array 2N times, and reads the always-zero high word as offset 0, cleaning up the object at offset 0 N extra times. As a result the referenced node or handle ends up with a lower reference count than it actually has (a refcount over-decrement), and binder's reference accounting is corrupted; for example, the owner can be notified of a strong reference release (BR_RELEASE) even though references still remain. Change the stride to u64, and read each entry as a u64, narrowing it to usize with try_into(). On 32-bit ARM, when this over-decrement would drive a count below zero, the driver's existing refcount guard refuses it and fires: rust_binder: Failure: refcount underflow! Cc: stable@vger.kernel.org Fixes: eafedbc7c050 ("rust_binder: add Rust Binder driver") Signed-off-by: Hyunwoo Kim --- drivers/android/binder/allocation.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/android/binder/allocation.rs b/drivers/android/binder/= allocation.rs index 0cab959e4b7e..f4ffc57a8cb2 100644 --- a/drivers/android/binder/allocation.rs +++ b/drivers/android/binder/allocation.rs @@ -251,7 +251,7 @@ fn drop(&mut self) { =20 if let Some(offsets) =3D info.offsets.clone() { let view =3D AllocationView::new(self, offsets.start); - for i in offsets.step_by(size_of::()) { + for i in offsets.step_by(size_of::()) { if view.cleanup_object(i).is_err() { pr_warn!("Error cleaning up object at offset {}\n"= , i) } @@ -412,7 +412,7 @@ pub(crate) fn transfer_binder_object( } =20 fn cleanup_object(&self, index_offset: usize) -> Result { - let offset =3D self.alloc.read(index_offset)?; + let offset: usize =3D self.alloc.read::(index_offset)?.try_in= to().map_err(|_| EINVAL)?; let header =3D self.read::(offset)?; match header.type_ { BINDER_TYPE_WEAK_BINDER | BINDER_TYPE_BINDER =3D> { --=20 2.43.0