From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-08.mail-europe.com (mail-08.mail-europe.com [57.129.93.249]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 028ED26F2B0 for ; Thu, 2 Jul 2026 02:18:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=57.129.93.249 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782958734; cv=none; b=C2fT6j/P2SAD4cR5upti9lmNxFeoP6q/ejIyDou1x2qmGViV3h3ScIU++9tGg9T/RWuVYTKFHE3GsHLlBbDF+jL2OvOlNjtesVfvzikoVuKVHijjcqs2WWk82TM1IsQR76z5ezepPSuRBO5f9jFUY2qyACxwmLlQNMZiDsBUSFg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782958734; c=relaxed/simple; bh=7/ez2+THHT/9gvK9u1Jh1DBEIhlF+06iy9vkW8F9AfE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=EeznPO8MSfaFvrfAXPmtrZCxCbj6nck39er/EYfHGZyiVU4OcGPPm/jSFXCyPV0LIdMhRSjzFj8NuSsIVwKPu3YzGHnUhowO0beUWedAAEbJq3+yEF2ddJ/KlhMNd/F75fmgHLy005Q9IouVsER+sGZtDX1Kbp2bD9ey/Hfy8Zc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antoniohickey.com; spf=pass smtp.mailfrom=antoniohickey.com; arc=none smtp.client-ip=57.129.93.249 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=antoniohickey.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=antoniohickey.com Date: Thu, 02 Jul 2026 02:18:36 +0000 To: Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , =?utf-8?Q?Onur_=C3=96zkan?= From: Antonio Hickey Cc: Antonio Hickey , Daniel Cote , Tamir Duberstein , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/2] rust: uaccess: refactor to use `overflow_assert!` Message-ID: <20260702021811.758731-3-contact@antoniohickey.com> In-Reply-To: <20260702021811.758731-1-contact@antoniohickey.com> References: <20260702021811.758731-1-contact@antoniohickey.com> Feedback-ID: 144211621:user:proton X-Pm-Message-ID: 79092b06d44e33c03591bff840cfba22e1a3d2e8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Using the `overflow_assert!` macro here adds documentation to the intent of the assertion, and avoids local `#ifdefs`s by encapsulating the conditional behavior to the macro itself. Suggested-by: Miguel Ojeda Link: https://github.com/Rust-for-Linux/linux/issues/1159 Co-developed-by: Daniel Cote Signed-off-by: Daniel Cote Signed-off-by: Antonio Hickey Reviewed-by: Tamir Duberstein Reviewed-by: Alice Ryhl --- rust/kernel/uaccess.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/kernel/uaccess.rs b/rust/kernel/uaccess.rs index 5f6c4d7a1a51..f04c913f23b6 100644 --- a/rust/kernel/uaccess.rs +++ b/rust/kernel/uaccess.rs @@ -11,6 +11,7 @@ error::Result, ffi::{c_char, c_void}, fs::file, + overflow_assert, prelude::*, ptr::KnownSize, transmute::{AsBytes, FromBytes}, @@ -655,8 +656,7 @@ fn raw_strncpy_from_user(dst: &mut [MaybeUninit], s= rc: UserPtr) -> Result