Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp441224lqt; Mon, 18 Mar 2024 12:13:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXHDJ986Ji9cxuZbpGidlnnEbZHskH+kdD0YN6rUoXv7S5oT7ZvTSZeIw8urdNKpxHI3MI7yO0XZ3WA8UCbRbwjftp3aQRLGkQ0b6nXuQ== X-Google-Smtp-Source: AGHT+IE8ojCronQLulrzMLjbSoBk2axYW6LGlcsROd72ld/WKfN7yMUwknQzcXX5BsYdb7stA7p5 X-Received: by 2002:a17:903:1249:b0:1dc:db57:d6e2 with SMTP id u9-20020a170903124900b001dcdb57d6e2mr708426plh.69.1710789231549; Mon, 18 Mar 2024 12:13:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710789231; cv=pass; d=google.com; s=arc-20160816; b=j98cY90s+pWKuAj02tg+MORtAl5/TfljsmwCfbt91o6yJkb56E0mhEEyFUOGXdE7sS Hl83CaiUScN5B8DHe345tHRnZSoApJaQkuVctT2EjijdyHtW7ezFrXk59TURCBchXbnD TDWw1OHJ3OyUSD3I23b516gnyR3jXvab8cBoi0x8+8Cqu5XKHqa8UeCgqoexZIZz/xYn hG3Ber8aNI8E30UzNDKkXhToxlG0mgX3zDKoTxo+x97sNOHlgpdEuIS2M/e207xRsZre S2+rK3K/QGgdZg47dTM84tFeBsyPUjLs2WkCmgaKisfphMwyJMlbgFRffqKkeI7t3zM9 V/iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=lIPYiS6AqT1tNRa+kXH/qxTnijO9SB6Y3hbgkaDiv84=; fh=bRP6M+sPQoGh0mLWrWmgZBeyapOS284a54mPf6Oezj0=; b=Yt/xt/VR1M3KxwYmwXEIncuWR7CgOqNZXv9RpXIbjDEd6GpZGO0aGk6aSSwOQ06KId KExfF7JAZhMUIQyMbUBPnlEpfT5Bl3cJ/Sn5EfgjFEEWsRCsn8iTu2qypFCL49E4TFHm AZikLNb93kZVN7z98R3vnIfGzrv02znGCkrFUlDdDYat51E0lCU30OdSm+c6VXhxcJ69 KU0ttF3naguaZGY4UD3G47uwkOCyuGdkzbOhNZUTkHa9tiTIQbpR4gbmksEJ/6kUsVm7 PPbaGIrwNStoE+GigoU682vyJu+Erih/0c7kOEFTiOUUck43MRCenbPfwZxsOGQEMoig prBg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=ohlCySQn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-106556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 mc3-20020a1709032b0300b001e024d34330si2690902plb.438.2024.03.18.12.13.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 12:13:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106556-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=@google.com header.s=20230601 header.b=ohlCySQn; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-106556-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106556-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.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 6C3C7B21ACE for ; Mon, 18 Mar 2024 19:13:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5E9FB56756; Mon, 18 Mar 2024 19:12:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ohlCySQn" Received: from mail-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.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 0356D56755 for ; Mon, 18 Mar 2024 19:12:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710789161; cv=none; b=SYT3yB53TVoce4Mj9zShGI5dH9u96vA2vH+Xhs8qZZ8Og8AL7MtM4ib/jyiPCgnkZ49+FDjISGPMT0W7Shb51HhCmoqfSgDy5VCHQZfhpWcmhSSPdPIlpRdkWYFC8TGubAqHDlzOBTeWOAM1NzI4Tpu2kujshE41xTEV7Hw43H4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710789161; c=relaxed/simple; bh=azAsnPQAVK2iBIAnXaor0VpPHFvaPYrmjfryKMkNBHc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=NWNqjZy0uPs6TAiNfexZ3d4hyBFrLDY2kw6Q6OZjWJdl2adsfTkNqgVr+3n61ieABvmsmi/ZPYiMoryu4cY/MLC/UMnqIk3TI/mqOuBcs9BiHx3GZRGeIShK6EjgYMiD/RvYIKi3MtSCiUUejgdaj4UwqEQ2C0LVPiqeAm5y/qM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ohlCySQn; arc=none smtp.client-ip=209.85.217.42 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=google.com Received: by mail-vs1-f42.google.com with SMTP id ada2fe7eead31-4765792fc76so990728137.3 for ; Mon, 18 Mar 2024 12:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1710789159; x=1711393959; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=lIPYiS6AqT1tNRa+kXH/qxTnijO9SB6Y3hbgkaDiv84=; b=ohlCySQnxier1SqXYCtxavbjBcoJEYaDwqDVXsUoUJG1wJdx6ISW0U2gvkfk9tMaIB f4p/JadXVx4vOcdKuHMGR/I0GBhx4H5JcLF6ULxAidWtajKTyQwOMXmr+LocMSDVmGIY JNqXky4pXo5vxp5l91VKsRBJSBcOONM1VNcow3VX8evSDhrWiYl0jjYrGlS/Pr+dQBt4 ef+gfk+6e4DX8R6Hi3Ggk8sxZnCSpftwBYZik3L2HiWvomExYOEliTTi+IYtBq0YR5Ih 3gt2C/jwJ4cMx9yqHe5LF+tLJa6qoz9XF33tnN8GRjGAu3QQ0/swcOCtUY3W2ER6lN8J fT8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710789159; x=1711393959; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lIPYiS6AqT1tNRa+kXH/qxTnijO9SB6Y3hbgkaDiv84=; b=NX/rSw2Fq4LjZzO5S1Tp7REV9Nl+TNyyd8+DR7kimA/7gztYJTC5lE4w2OTtPzyR0X NAC1Ek9dC+BA212651QH64pgDntKrCpVkx5CGY8bwUYdCeTngb1a1aqaHENOAesUnWv+ QEqIaOxevXlsG4Lf0SHDOJN38Bw2R7weV/vjKipflg5CApjUC/y/z7a9VOpVFaFuqj47 AN7JKAycgUuQE7hiALtIr54hQEApaVJJY4nbu34NBs96d8ODTneqAyk4uYn4x2g57QC+ r8Uk8bnmCjXNe3qGSQnHHAhgZ9Wq+PUKYJwFTKxy6xl3XdBiVm2VKvN7D/UIYiWRplvN PC3g== X-Forwarded-Encrypted: i=1; AJvYcCVHk+qdqSK4oteIjRs1QiWkosdAtZoo+J6hVtVcIGht0aFpK/9dPQXh9PIgiYnybcxnjdYiUwGBl0e+HN1dvE+dKhlvLkpFBAb51Fio X-Gm-Message-State: AOJu0Yz39atb/bdnPsqu4AWnDid9RYGhnz0caYqGht/+NT7gJYPcFi28 Y8Lg7lDKhjkVIqP6HGY/1sOV403RsFs4yE9b4+nIURdnn3GhoJ27SOg7lixKiOc/YPKVWGMdwqW E6ptSJa6p7hhYhpVhIev5Xad9DDWZyYUetBcI X-Received: by 2002:a05:6102:a54:b0:473:ac82:27dd with SMTP id i20-20020a0561020a5400b00473ac8227ddmr329639vss.6.1710789158712; Mon, 18 Mar 2024 12:12:38 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240311-alice-mm-v3-0-cdf7b3a2049c@google.com> <20240311-alice-mm-v3-1-cdf7b3a2049c@google.com> In-Reply-To: From: Alice Ryhl Date: Mon, 18 Mar 2024 20:12:27 +0100 Message-ID: Subject: Re: [PATCH v3 1/4] rust: uaccess: add userspace pointers To: Boqun Feng Cc: Miguel Ojeda , Matthew Wilcox , Al Viro , Andrew Morton , Kees Cook , Alex Gaynor , Wedson Almeida Filho , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Greg Kroah-Hartman , =?UTF-8?B?QXJ2ZSBIasO4bm5ldsOlZw==?= , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 18, 2024 at 7:59=E2=80=AFPM Boqun Feng w= rote: > > 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) -> Res= ult { > > 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 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), though, since it is used in `Page`. Alice