Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp451345lqt; Mon, 18 Mar 2024 12:34:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXR7tG1MYyQSVM4n/33ScjgBvSI0Ej62E9AsZVmSyXuYeZPjb0Uuh6bVfv9GotAlBG1VNiCHYFyGhFe1VhGmOoh0+hZiLoAVLCGbtGEAw== X-Google-Smtp-Source: AGHT+IEuy5x8+NZ2oJZmI/BPPjOOKNYaoYcdEeO6xaAjhdMaRKAkRegNhr6our5XCpmxlxSx5VeM X-Received: by 2002:a05:6a21:2d8f:b0:1a3:522d:c0b5 with SMTP id ty15-20020a056a212d8f00b001a3522dc0b5mr7696828pzb.45.1710790442486; Mon, 18 Mar 2024 12:34:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710790442; cv=pass; d=google.com; s=arc-20160816; b=S21nRAhDQ+3N2h2Z6BFFWwxLDPKQYbAWxLns4NYLMxLhlASJHTdXFbnib/UQ/G0SeV u5IshMefPr8OCqY9g2ebpHxBuLslGICftKR2ycFXj6zukdTXOYB/5X8HvBINCUPaVfM0 J7BqwL+bL1oZoArqonsm/nscwo1wPg8SLCTqkvIVukf4cVcmlOWbtMtpGEY/OUSZMNuA dvJKOHCha9sPUEfntA7N9uKCZlkvowjSb74TjHxqAQ4yVTCDcY7VJWln0zof0kJ1rUdZ MqT+pnJmmGdjU5ZIYafj71Co7UPOutouLYyfJ1PLDC6qxoi1ZgDQEpwAlvraTdnzKnmv bU0Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:feedback-id :dkim-signature; bh=e/vcR/G2jUCRQOvGxjdpHUEzdMswpJzejJydIrt8p88=; fh=WxGyhwzRt79/UmOTpxQyjT80DrDMq0TsbSALiNf03bM=; b=DJ5V2iBbwKcdJ/1N6ZX4skIIjQx1FK/0ZM4Mvu1VkIsheSqrPSrD0jgYqeQXQLq3F5 sFmSp13wXH714aYhm99d7OgEtPdB92BV8D+oBc/P4ujeBecWQpx1I7sIWWLHBjo/5EB6 WH3CtL7nvjstBYLfeUGr+N2UUcQTbIWFKaOnXCxUctxGg3O0DLHpxIIT8W9dswPZ3K0o VOOqQch76LjaEJ8ROT0VsH9pQ+7rlKV0OwBUVSudi7ANhkwj8AggO/M6MDYKzdReh/Kx MiCpEdrZkwcAvZvDSNI6YKY6O0z+w+cQDocc8zdr1aVDMupkiL76piJ5pWcXr4NwjnlG 6fJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JTtiht4X; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-106570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m5-20020a632605000000b005dc4e366f46si8800649pgm.127.2024.03.18.12.34.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 12:34:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106570-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=@gmail.com header.s=20230601 header.b=JTtiht4X; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-106570-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106570-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com 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 7AA7EB221D3 for ; Mon, 18 Mar 2024 19:33:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4768156B83; Mon, 18 Mar 2024 19:33:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JTtiht4X" Received: from mail-ot1-f42.google.com (mail-ot1-f42.google.com [209.85.210.42]) (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 EBB4B56468; Mon, 18 Mar 2024 19:33:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710790427; cv=none; b=Mu1JJo62nXSSF3s0DN021VgSCIxaVY+97nvBk2On+srIVja4PSwoNT6adbDauvzdK4898ap0hW1zKxV5sUOlUw/VywD5y4gJxKPI1JxTGpqfm1jZDBt6D7gfFwytRyt/WDNtaH0uN+K1N7a2ymL7VSeQPlw1c1xgpFINmg1OsWE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710790427; c=relaxed/simple; bh=uPxVSnVSbl5l7qo1E3lKmpBywF3ZcXQe1tAltEs5ke0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qVNMqG09cdzLuJUSVy3p2o1MhHKU7SFClBA7qgD2kTJac6itZi3g5VH5woKJaUfjPlV41L7K/qrbJ6ONUjQ2L81csWDS7N/rW5+FjgbJFWj6c2er/iWwVWCGidyGYQeJQN5i6IiW8AfjrIc9TQsp+uqYubGfQ+PVH4rMUBi5yZY= 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=JTtiht4X; arc=none smtp.client-ip=209.85.210.42 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 Received: by mail-ot1-f42.google.com with SMTP id 46e09a7af769-6e69543fc1eso693536a34.3; Mon, 18 Mar 2024 12:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710790425; x=1711395225; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:from:to:cc:subject:date:message-id:reply-to; bh=e/vcR/G2jUCRQOvGxjdpHUEzdMswpJzejJydIrt8p88=; b=JTtiht4X8rFDL8WoseDNFGn2H3r6LavW5IngnVOqcOV1nrSKeFz6/LX8LdHvoYTTGl 21ASQMDkgTxrVDW9+L3Gj8PP22d5D4QneYLcGPhZ902ZTiCAhbwsRDk6/nobr15aNcCS Xqv0KqM+x9PQpWzneb7jvx4qcWzDQEesb8ZNdx7NjvrkyXEQfSIXqBJrNaS7/5/j8yps LAKwMGOmP8Pq0gjwzq1NkyyfZG3AnO4XYlpXGOB4Vtb5cNsVQQjtjnaKDPI8cOxFh8KQ aqzn0615F3K/sewSdS8M0CbaAIVn8esAz2FKSP+jDaE5sN3Xu3E4Hy1cFS2KK2pqGSPU qnbg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710790425; x=1711395225; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :feedback-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e/vcR/G2jUCRQOvGxjdpHUEzdMswpJzejJydIrt8p88=; b=ieWXv5M71mPRAyV3q5cdriaUnYZn8oP32RXMaqEW70HcXzI5Yz886LGK3MCs8yWUeY WOOlurj3GD/jubWC2GDZRH9Bzxzpmodj/cQfNiiH2lzXbo6rUDoRDXqn7htJMNG8diV5 OvdE3d7ITMDjK5Lluz9AvY2VNvS9Y559xhb7eG6rTpl6cDmWTyK7vTFtIYMVoygL5Lu9 Fgre7aDVx5ocC0M4CdCcesqQi3A4TAIQ4AwDBk6fN+RJHmEGQletx1gKAIsEEV5LO3Rz s4n9JUbRtxqPvgH6qgI+3VJFhw/OGK/6hRaCfb2WnrOzPO461XTrMPq/zkJYJYT7lk1G +Jgw== X-Forwarded-Encrypted: i=1; AJvYcCXiWievHcYvXpIt0HQn7UpoPycoEZMXyCm6F0PeQVHRFEGYsgczV0t8kIuyO5fJXg8Nz0NrCW10/PAthTU8c0pfWyYsNrykqEr0Jj3aUoPH2ha3dQm+yK7zXRqJoZR4INk1VZbboLyDrRuW/JM= X-Gm-Message-State: AOJu0Yyi2UJTNjDBZLwHtUXAE/g6uv2d1R1zeKggWpmvngym9LG/KHf2 32vcya3fLW/Hzw7F744VuPfMhLKmh7k+zLFdT8be6mnPhTL5m0M2 X-Received: by 2002:a05:6830:314a:b0:6e6:9847:8ef3 with SMTP id c10-20020a056830314a00b006e698478ef3mr3074103ots.20.1710790425025; Mon, 18 Mar 2024 12:33:45 -0700 (PDT) Received: from fauth1-smtp.messagingengine.com (fauth1-smtp.messagingengine.com. [103.168.172.200]) by smtp.gmail.com with ESMTPSA id g21-20020a37e215000000b00788663d8a1esm1701175qki.112.2024.03.18.12.33.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 12:33:44 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfauth.nyi.internal (Postfix) with ESMTP id C94171200066; Mon, 18 Mar 2024 15:33:43 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Mon, 18 Mar 2024 15:33:43 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrkeejgdduvdeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggugfgjsehtkeertddttdejnecuhfhrohhmpeeuohhq uhhnucfhvghnghcuoegsohhquhhnrdhfvghnghesghhmrghilhdrtghomheqnecuggftrf grthhtvghrnhepvefghfeuveekudetgfevudeuudejfeeltdfhgfehgeekkeeigfdukefh gfegleefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh epsghoqhhunhdomhgvshhmthhprghuthhhphgvrhhsohhnrghlihhthidqieelvdeghedt ieegqddujeejkeehheehvddqsghoqhhunhdrfhgvnhhgpeepghhmrghilhdrtghomhesfh higihmvgdrnhgrmhgv X-ME-Proxy: Feedback-ID: iad51458e:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 18 Mar 2024 15:33:42 -0400 (EDT) Date: Mon, 18 Mar 2024 12:33:32 -0700 From: Boqun Feng To: Alice Ryhl Cc: Miguel Ojeda , Matthew Wilcox , Al Viro , Andrew Morton , Kees Cook , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Greg Kroah-Hartman , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Carlos Llamas , Suren Baghdasaryan , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, Christian Brauner Subject: Re: [PATCH v3 1/4] rust: uaccess: add userspace pointers Message-ID: References: <20240311-alice-mm-v3-0-cdf7b3a2049c@google.com> <20240311-alice-mm-v3-1-cdf7b3a2049c@google.com> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Mon, Mar 18, 2024 at 08:12:27PM +0100, Alice Ryhl wrote: > On Mon, Mar 18, 2024 at 7:59 PM Boqun Feng wrote: > > > > On Mon, Mar 11, 2024 at 10:47:13AM +0000, Alice Ryhl wrote: > > > + > > > + /// Reads raw data from the user slice into a raw kernel buffer. > > > + /// > > > + /// Fails with `EFAULT` if the read encounters a page fault. > > > + /// > > > + /// # Safety > > > + /// > > > + /// The `out` pointer must be valid for writing `len` bytes. > > > + pub unsafe fn read_raw(&mut self, out: *mut u8, len: usize) -> Result { > > > > I don't think we want to promote the pub usage of this unsafe function, > > right? We can provide a safe version: > > > > pub fn read_slice(&mut self, to: &[u8]) -> Result > > > > and all users can just use the safe version (with the help of > > slice::from_raw_parts_mut() if necessary). > > Personally, I think having the function be unsafe is plenty discouragement. > > Also, this method would need an &mut [u8], which opens the can of > worms related to uninitialized memory. The _raw version of this method make it a `&mut [MayUninit]` then? If that works, then _raw version is not more powerful therefore no need to pub it. > is strictly more powerful. > > I don't think I actually use it directly in Binder, so I can make it > private if you think that's important. It needs to be pub(crate), I might be too picky, but avoiding pub unsafe functions if not necessary could help us reduce unnecessary unsafe code ;-) Regards, Boqun > though, since it is used in `Page`. > > Alice