Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2307169rdb; Wed, 21 Feb 2024 03:47:55 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVTP1IEdGSHOj5kVEYD3+xsh4+veMq1i5sOZvtbYscPor4Ik2R1q1Q+CgXnWiKMlbaSwosidrTdhAHXLB1iBVjWu8Oc0U7RkEKfDm5lEg== X-Google-Smtp-Source: AGHT+IEJPLonWHqQVeZjU8H3BFD3atQtJFYgr+QjEFMYHPLPzZSEp17+Me8JSD/oxRzot6Z19nHS X-Received: by 2002:a0c:de10:0:b0:68f:3dce:7b99 with SMTP id t16-20020a0cde10000000b0068f3dce7b99mr15450281qvk.3.1708516074756; Wed, 21 Feb 2024 03:47:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708516074; cv=pass; d=google.com; s=arc-20160816; b=XsNlLV7x9mW/NQoPmzBuoUhBRhp6N3jW3nRnWeIvhy9HeRZYId7AuO562XB/CMtEMq q4JT/U1E1rx73Kn7GHESKRejrdIVyUWx/aX6pnCPKWgPo4KxSCzD9ykMqQ22JOGM1vW4 Yiy4u25gTAWqGYOJCNzrcaZse+GO/a2BH78APlMYpDGUbPx105kZPkfh4Uqk0TyhXqYu jtV1LUWpDeWmg/is98kg8FAdyjRl8L9nCjBAW9IIhXCrliRXoxMeKlLZ7Uw6RgG7fSl/ x+JquBOAMyBaderV/NFUJp5ORv+sV7rh6D+uJg4jnPzobgXNC0WLh4aT6zzURieXrFGK Lmbg== 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=JyovQl5iGkP+14IRCuKTQAaTQ48NTlw9CloKE2arYCM=; fh=WhS4OwCv7DpVqXKS0otvccIvDdgB9CaRvOMGSlPtpOQ=; b=f5fKGJvawiolnr7UzEAWoHu7b0pEeBwgnt48bfWHZjVz3QG0a9YtmwCLFSSq4YCreJ 37o2Hy3n/AyMvEBqtJrw/hO2KIKIF2EEvdJyEoDDB99Fd81MqXHyHSCo8iUsLYmYVUjz h5/nJe3qPkAdtq4+OgSjLbUGUcdrCF4W8Q4bUeEADdei8duln+PCe/G4ineITjTavdGg i5gPdwHVdNmQcx4aOzEBFIoh28tirgzfKjvo6yu8eKvnnL/XUIWI9DeVet3Mr9hl/TAW rdbDUjATDVBdGVn+oecT3BAWiVI2YX9yHcP+OmkzeoLcQ8tCkWjCMAdmFweAeXLqzsg0 8Exg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="T/tiHVVf"; 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-74657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74657-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id ib12-20020a0562141c8c00b0068f3fccc515si10650643qvb.394.2024.02.21.03.47.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 03:47:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="T/tiHVVf"; 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-74657-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74657-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 83E341C22B6D for ; Wed, 21 Feb 2024 11:47:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F0003481AA; Wed, 21 Feb 2024 11:47:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="T/tiHVVf" Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) (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 6C31947A5D for ; Wed, 21 Feb 2024 11:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708516059; cv=none; b=VM5IEMjpOTXtecuFGvykDVZJS44thPzv6BJGze+4unwN4SV4mZ3wAOWLdVpPXzy3WiaFIb/O6bjrlFaBSdJ1R7StGB/BbVlWdurZyjOlm6apIFOruWy7Psai1hQaILuWTmpjHuhciGGYaxeuglu+xcSUukmwc/+3Zj3zFdDYGLc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708516059; c=relaxed/simple; bh=vRt/FdxzDOQ4l3rxiit+Wes79HUFmm1mgOJQtV+4Bcs=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=ccaKOQZLCMURvUaexZ9es0OSn6lDhR2B+80bbrF0FuUpqR49rMMckTKXTyaJ/qXmWqmZ5uRtlU7MqHVXgJuy4pBFqcohy8V10T81WrRoe6nUG3oOTgNIJCX0FBYOdu04OmqD1r6Xvft+sqvTsuAX7o51aObfGzfu7C5TKzGtLaI= 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=T/tiHVVf; arc=none smtp.client-ip=209.85.222.41 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-ua1-f41.google.com with SMTP id a1e0cc1a2514c-7d5bfdd2366so247299241.3 for ; Wed, 21 Feb 2024 03:47:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1708516049; x=1709120849; 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=JyovQl5iGkP+14IRCuKTQAaTQ48NTlw9CloKE2arYCM=; b=T/tiHVVfCLOxXrj6ZM5mdpGBEX4GAZrjjqLFx7iK0UI6fGTJ/ppU7LQFvKvDV+wE5s QiFhPiKEgYya/tJRt48lGp4H1xr6gYQt7CxoZVAX+Tv5g22/bPGk8TuILoPMSFFX/tgv s1fBeV8MbnM3NN+AHADQPS9hY3bznH0hEjl9DSFMoYAjnW2f2DjdpMRX16Th4Ue7V3Ad 5tE1r/rhIBv8VVMXTBcSkXJUrSC+51hcIZFL+0ZfecK3B9SYT2AspBjiY0cTLB8Rr2i2 FYd8r9A0rl8WikK8JipBA5aBfimNVLLNF1pqiKO1SkxeB+W9BCN/bzCu4cej0XOkqrqi CWiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708516049; x=1709120849; 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=JyovQl5iGkP+14IRCuKTQAaTQ48NTlw9CloKE2arYCM=; b=Ouo9x7/5XYbFZm7fhinrOVqhW16YBLGZ/sAEodaMsk6C0oIH/yUTeBdfyW8Hzxwvuz RQLj5hAkLyPR0cpXiGvqB2uE/kA+TZzlmKiUp3QeRyWAfQ7qQHv1CTdHDnaVVOc9jHjH KYMQQx7VOc0QxhOfxWXckXjfC26rphI536Fa4hqSwlXgwcli3tFz1AG7S998CsB2y+Rj Vewh4uK+Id+0VU3qapP2O0I94yeIwGLo+FA4WXe985KjfwTP4N7y+vznCws4cEnlvqL0 xKyVR9A62EOq6K037DGFY8Ir/BoPOVBidqfm/zFEJKjXWtiWtRrkmk4qyK7D/mU12OQh zenQ== X-Forwarded-Encrypted: i=1; AJvYcCXVLDFpbvDj04WqYTal8vfsG5EgjdEZ4NLns21cpzZwx+QbdEkTXYLT1Wl0RH4y8rBnlbCjWy4c/c5rR0i4JxCzWd1GUOkBs5k8d21p X-Gm-Message-State: AOJu0YwZSn9dm575Zd+xWB6yZu2yxdp/uuiED5Z0Rvy6qa3ehCbl+tEx +EEN7uQAFk4q/J1CmqxnkAh88BSaN/8/DHE4W2yGlRDdlm98cxcM+ZeE8+n8rd/Bl7z87xTUzye BW4DQ3ofKqaAZlgnG3SELu0C/rhqBQZ+F6Arq X-Received: by 2002:a67:ee08:0:b0:470:a138:78f2 with SMTP id f8-20020a67ee08000000b00470a13878f2mr1527074vsp.4.1708516048942; Wed, 21 Feb 2024 03:47:28 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240208-alice-mm-v2-0-d821250204a6@google.com> <20240208-alice-mm-v2-1-d821250204a6@google.com> In-Reply-To: <20240208-alice-mm-v2-1-d821250204a6@google.com> From: Alice Ryhl Date: Wed, 21 Feb 2024 12:47:18 +0100 Message-ID: Subject: Re: [PATCH v2 1/4] rust: uaccess: add userspace pointers To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Kees Cook , Al Viro , Andrew Morton Cc: 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 Thu, Feb 8, 2024 at 4:48=E2=80=AFPM Alice Ryhl wr= ote: > + /// Reads the entirety of the user slice, appending it to the end of= the > + /// provided buffer. > + /// > + /// Fails with `EFAULT` if the read encounters a page fault. > + pub fn read_all(mut self, buf: &mut Vec) -> Result<()> { > + buf.try_reserve(self.length)?; > + > + // SAFETY: The call to `try_reserve` was successful, so the spar= e > + // capacity is at least `self.length` bytes long. > + unsafe { self.read_raw(buf.spare_capacity_mut().as_mut_ptr().cas= t(), self.length)? }; > + > + // SAFETY: Since the call to `read_raw` was successful, so the n= ext > + // `len` bytes of the vector have been initialized. > + unsafe { buf.set_len(buf.len() + self.length) }; > + Ok(()) > + } There's a bug here, since read_raw changes self.length. It will be fixed in the next version. Alice