Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1246318lqd; Thu, 25 Apr 2024 09:40:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjE58Gsax+JH6uImHlYxM3O8oHOFK3E+UFzJzuLnqzfBo4y/Mt9TTkNIIwHMCNVC+9HPUiE33Jz6+/wAeJphDsGBHhGF8aaTye7APcbw== X-Google-Smtp-Source: AGHT+IF0tKRmLDa6ZcSgY0Bnx0dI9eTcZ4Jf92a8r/0ONcLuLTvompBffgnpaHM4lFaTYbmTluvs X-Received: by 2002:a05:6a00:2190:b0:6e6:fb9a:fb45 with SMTP id h16-20020a056a00219000b006e6fb9afb45mr377579pfi.1.1714063226025; Thu, 25 Apr 2024 09:40:26 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id gm8-20020a056a00640800b006eaf877dcb5si13516136pfb.372.2024.04.25.09.40.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 09:40:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@garyguo.net header.s=selector1 header.b=ULNrofaM; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-158877-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158877-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id CAE7DB27CC4 for ; Thu, 25 Apr 2024 16:15:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07CB414D71B; Thu, 25 Apr 2024 16:14:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b="ULNrofaM" Received: from GBR01-LO4-obe.outbound.protection.outlook.com (mail-lo4gbr01on2092.outbound.protection.outlook.com [40.107.122.92]) (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 B3A6614D28C; Thu, 25 Apr 2024 16:14:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.122.92 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714061647; cv=fail; b=jr6lQe3VL0zjIvMUbZCMJtTZ8NrQa/fJ1JdVHH7Erl8uZahIUOKojoTbNW4j6+uw0GTWGSKTNMX1tJzHSq4AygnN/dOnn/9vgk6Yqo4BY+EeNhaW9m+180mp6NErT2cvE7uu6zTmXd+YcpRrRJsnG5IW6ioB9Nv7VV0ZwBxqHzQ= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714061647; c=relaxed/simple; bh=B3ZvofMv/LYkm9y8o+eScz/5uLtowDeDt/0uuL4bCjY=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: Content-Type:MIME-Version; b=FkcpCrI2rLUgXqFqEGrhg2cpSII+BwsX1rxIEfvSKxEl1WdRXLnT+lzT4ZX9jDhb6nj3oyU1+HQAScB6SobhGMGFD3ffYLeLJO69kifku1lWIn0MUKHDOiWPyimDAQssC/82SMylXzGhyahMwVJkRuKx5dvujmTfP0EX3ZY9wpY= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=garyguo.net; spf=pass smtp.mailfrom=garyguo.net; dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net header.b=ULNrofaM; arc=fail smtp.client-ip=40.107.122.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=garyguo.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=garyguo.net ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kH8qNqIu5oEyvzykULUNRkEtz6wA/zTw69qgTfjWA5GoAlbt27qsT/mce8wjXbyCFQnO2Yzjv6aFDhK8fxR6mTbxszTf1i85iPsrbZ5SunWAIeJGtgd/1YhjqKtKF485gs8kCbTU/PPbVU85Rut99bKShR5ZMWITyJAEGFbzJ+wHoEMMhs/5jjaSJDuasA+gDCt+tlXg9DzvEE/AM4NxmpoekaPiLVK3wPw95Ys424BkryIEikZjkyUwY/IrdAWR2voozwyEzvNPbEAc/vnX2OVUWZMI9gyuqao6jk9gBkgdF+4X5hxW0J4NpsEpc5Uy01xMSBGmiEwCYWj9OvjWxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ep/WTszA2WkQDXe+kAenwxtFlCAbYxNsfy38azCFbA4=; b=fbXwCrC+t2a8Gh2li1Wkxc3ZBJaPt1ijNrX5x9/Ualm+Uga62sjc1Wpl8+7+hezZ2tLXkxE0hLftSRIId/DjDjv11q6PE5Er03Twf6sEhIq4VFJSey9W8QdyRmNzjvkgOjWXW+ypGTep+i9kJyE5FiaUxWPkJX4r3XxSDLEjxAs+f19QZ9lhBnLrL3HxswWl2aOLSRGMzQirkquSZv/aii4uU/Z7BLgp8G8MrtDhG9owQj/igG8R/7u0c32IidGqfBYuLrPiUYolo4ueenKGSg7MKH7UtC/UBZSN74InLSKgv6F/uzpJeTiw4NYTgjYYp7sB4Lzc7E2JlPNZmnQOIw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net; dkim=pass header.d=garyguo.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ep/WTszA2WkQDXe+kAenwxtFlCAbYxNsfy38azCFbA4=; b=ULNrofaMYjEM3tkTKs3P6LgMt439Lu54xZPF3TQmHZbBFsf5zf76k0Gb1t4WJSf4AcKWkG9II+VlZi2/zZdLUtTg8fyoi1L+WRBqSe3BHDgBvjc+HJADoo/ft5niN0ODWMcSU0Bohadpe7NI6XlYVAj5q2jJlh+iko7QOdG1NEU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=garyguo.net; Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) by CWLP265MB5970.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:1cf::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.22; Thu, 25 Apr 2024 16:14:02 +0000 Received: from LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::1818:a2bf:38a7:a1e7]) by LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM ([fe80::1818:a2bf:38a7:a1e7%4]) with mapi id 15.20.7472.044; Thu, 25 Apr 2024 16:14:02 +0000 Date: Thu, 25 Apr 2024 17:13:58 +0100 From: Gary Guo To: Alice Ryhl Cc: Miguel Ojeda , Matthew Wilcox , Al Viro , Andrew Morton , Kees Cook , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , "=?UTF-8?B?QmrDtnJu?= Roy Baron" , Benno Lossin , Andreas Hindborg , Greg Kroah-Hartman , "Arve =?UTF-8?B?SGrDuG5uZXbDpWc=?=" , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Arnd Bergmann , Trevor Gross , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Christian Brauner Subject: Re: [PATCH v6 3/4] rust: uaccess: add typed accessors for userspace pointers Message-ID: <20240425171358.54dc96e4@eugeo> In-Reply-To: <20240418-alice-mm-v6-3-cb8f3e5d688f@google.com> References: <20240418-alice-mm-v6-0-cb8f3e5d688f@google.com> <20240418-alice-mm-v6-3-cb8f3e5d688f@google.com> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P302CA0002.GBRP302.PROD.OUTLOOK.COM (2603:10a6:600:2c2::8) To LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:253::10) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LO2P265MB5183:EE_|CWLP265MB5970:EE_ X-MS-Office365-Filtering-Correlation-Id: 3eb642ba-7e25-4c00-4741-08dc6542b905 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|366007|376005|1800799015|7416005; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?8G/L776Wnv6DbtGhAgn6HMnGi2OAE8SjKXvqZIYPEG7qLtx6V2KC1NRZGb2T?= =?us-ascii?Q?K6WCOjrkBEzDzGgv1AeIvVPba8MmrKgUokNG+zy5gXXd38ErX8m0yVNrJXvq?= =?us-ascii?Q?4Ot58KA+xVNT9OUdgg3W/tpBxV9rGSV/ULvOp4adfEwJ9Y6LTLSHjJlC+DAq?= =?us-ascii?Q?WlR9Z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v1EBFAVIHSJC?= =?us-ascii?Q?ke33KUPVOqU6CMiacKQZHX+bgYngBkFvAEhOxMTfZSwR+HTP2s/iqdeCl/sK?= =?us-ascii?Q?EgV5h8M2CfVkXoxRKXCubxs4Slvy8+qiK0Fo1g+DjVVil57rXJU8C0nG3ROB?= =?us-ascii?Q?KBoKdr1LJTlVnTW0ZvG4g9yCDAIJB6eONC5U5dre7rOB06OYFKuATcYD0T9U?= =?us-ascii?Q?OcAxUJuvi5i3iYonFTT0klFM1AbC7e9Z0Ds87jGzxw=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(366007)(376005)(1800799015)(7416005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?OP/iGgRX26+mOxvzl/+tMM+FDkSPSuV+HKQ7zg/4IogwWprAI44tiuDL/TQ/?= =?us-ascii?Q?bFGQ3wsPFzO2V/SEGBe5bSX4HjjiUVwbQuEZUrUacm+5QtlXpR7xTnSVFdQJ?= =?us-ascii?Q?PG3aMD7JiONduTHYFCzxHM24+yP+hfTWYxlrX4InwDi5Isi/3SmXzDAmRkjz?= =?us-ascii?Q?OacLpdP5Ucz4FVasA8a9vXC/fBM38kiQbyUXFYvwAIv+lNbZuaAbiXN+vtxe?= =?us-ascii?Q?3cmop3V49wJvteCvVKo0kUlnz6DSdUefArEzd2nGmk8F0pwPUCO02Ma9AsZ4?= =?us-ascii?Q?0peOJwRwupBHHAfp662NmFMJOszyemhsaupbur0c/ObVEFsTbtmoq1ElGcvA?= =?us-ascii?Q?WeltL+X8/x76f/7BNPYXI61tB5I3jwYSDsVimPmfbmo2AxmNlL1F27Tp3+5q?= =?us-ascii?Q?xeaIBIXdhTz/5tiw9EH8Q7GQNY0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Q?3IrsL0SQk4OTQ6BHEQ8AyU7mqlTTY7Jy3RHKcoKFF2LF5HJZq6knilmq2V32?= =?us-ascii?Q?wjv5/HSqe6LsjkWzc4Rv4mKm8lTj4b87Jo2in9jad61fvtoMBJ6qGkSsbouF?= =?us-ascii?Q?JsA8rFJrFrcsKu1UHPv+va9VryqtfZNRw32uzkmBaATPsZvH79albQ4vwf95?= =?us-ascii?Q?qicW6M0LhbwSGnxjzpTdb+VO0ZImONh1K10fpYBBZF6nJ3CEKvqFMAg7ZHla?= =?us-ascii?Q?JmnxYZHbvH19Y727+QSRrzIOesU97OUV7F04H+nH?= X-OriginatorOrg: garyguo.net X-MS-Exchange-CrossTenant-Network-Message-Id: 3eb642ba-7e25-4c00-4741-08dc6542b905 X-MS-Exchange-CrossTenant-AuthSource: LO2P265MB5183.GBRP265.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2024 16:14:02.7654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bbc898ad-b10f-4e10-8552-d9377b823d45 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: eQMgL4gAAKImO8lMZuR6fOwwEVPmh8ORlY6NXvY1saT97ma12sXvs8Mro8sx4KUr11UEngJY6Bd6RNVE/mvP0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CWLP265MB5970 On Thu, 18 Apr 2024 08:59:19 +0000 Alice Ryhl wrote: > Add safe methods for reading and writing Rust values to and from > userspace pointers. > > The C methods for copying to/from userspace use a function called > `check_object_size` to verify that the kernel pointer is not dangling. > However, this check is skipped when the length is a compile-time > constant, with the assumption that such cases trivially have a correct > kernel pointer. > > In this patch, we apply the same optimization to the typed accessors. > For both methods, the size of the operation is known at compile time to > be size_of of the type being read or written. Since the C side doesn't > provide a variant that skips only this check, we create custom helpers > for this purpose. > > The majority of reads and writes to userspace pointers in the Rust > Binder driver uses these accessor methods. Benchmarking has found that > skipping the `check_object_size` check makes a big difference for the > cases being skipped here. (And that the check doesn't make a difference > for the cases that use the raw read/write methods.) > > This code is based on something that was originally written by Wedson on > the old rust branch. It was modified by Alice to skip the > `check_object_size` check, and to update various comments, including the > notes about kernel pointers in `WritableToBytes`. > > Co-developed-by: Wedson Almeida Filho > Signed-off-by: Wedson Almeida Filho > Reviewed-by: Benno Lossin > Reviewed-by: Boqun Feng > Reviewed-by: Trevor Gross > Signed-off-by: Alice Ryhl Reviewed-by: Gary Guo > --- > rust/kernel/types.rs | 64 ++++++++++++++++++++++++++++++++++++++++ > rust/kernel/uaccess.rs | 79 ++++++++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 141 insertions(+), 2 deletions(-) > > diff --git a/rust/kernel/types.rs b/rust/kernel/types.rs > index 8fad61268465..9c57c6c75553 100644 > --- a/rust/kernel/types.rs > +++ b/rust/kernel/types.rs > > +/// Types that can be viewed as an immutable slice of initialized bytes. > +/// > +/// If a struct implements this trait, then it is okay to copy it byte-for-byte to userspace. This > +/// means that it should not have any padding, as padding bytes are uninitialized. Reading > +/// uninitialized memory is not just undefined behavior, it may even lead to leaking sensitive > +/// information on the stack to userspace. > +/// > +/// The struct should also not hold kernel pointers, as kernel pointer addresses are also considered > +/// sensitive. However, leaking kernel pointers is not considered undefined behavior by Rust, so > +/// this is a correctness requirement, but not a safety requirement. > +/// > +/// # Safety > +/// > +/// Values of this type may not contain any uninitialized bytes. This type must not have interior > +/// mutability. > +pub unsafe trait AsBytes {} > + > +// SAFETY: Instances of the following types have no uninitialized portions. > +unsafe impl AsBytes for u8 {} > +unsafe impl AsBytes for u16 {} > +unsafe impl AsBytes for u32 {} > +unsafe impl AsBytes for u64 {} > +unsafe impl AsBytes for usize {} > +unsafe impl AsBytes for i8 {} > +unsafe impl AsBytes for i16 {} > +unsafe impl AsBytes for i32 {} > +unsafe impl AsBytes for i64 {} > +unsafe impl AsBytes for isize {} > +unsafe impl AsBytes for bool {} > +unsafe impl AsBytes for char {} > +unsafe impl AsBytes for str {} > +// SAFETY: If individual values in an array have no uninitialized portions, then the array itself > +// does not have any uninitialized portions either. > +unsafe impl AsBytes for [T] {} nit: I would move `str` to here, since `str` is essentially `[u8]` with UTF-8 guarantee. > +unsafe impl AsBytes for [T; N] {}