Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1723187rdb; Thu, 25 Jan 2024 04:27:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE9A2qANHEqRZ2hKGj/8nUFZ+VkCcpjfH0mSsxROXPh1zj3dx0vgNg2Yct9bBU+L9F3rqSa X-Received: by 2002:ac8:5a91:0:b0:42a:30a5:b4b1 with SMTP id c17-20020ac85a91000000b0042a30a5b4b1mr1343729qtc.39.1706185643888; Thu, 25 Jan 2024 04:27:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706185643; cv=pass; d=google.com; s=arc-20160816; b=EKbjqKDkIp6XAP+zJRgccprvnPBpkbYateJ5krMaAl2zGEreDZJ1njPlkqfs5hTzen I0OvtsEWs7b9tunkjW2RexcT/DbV57qwxHiuDaP4yfBbOmPEwfKjOrb90UAefYrp9kJB pQJYcLgdK/FRon3WbxZygPIncD6pkWnx9PNi4bUpkEC6mAFpaOZuFves0Mvl/mTfzaUu V6N5LsGNy7R+seY37dh0t9zNDgVSb6vuUDOODSLSBIgOT4PuikCAq7JBhyiQSOVTDjlL qvdf2hl09fVpVJapGhGjSXmxlWVTx7uOW2kReHC6UVgvR6nHuoFYweA1BqPYii0oVz04 myng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=by9e17p4SbOQuMUvw9yQVjRsSkMsUr3SrHfJ/laHRbg=; fh=wQZ9dGUOgImhdH+pMZAGb4yuoSa47a8LcxF3eE7fdps=; b=Vno1DAA+/h2MGgpC8WldVXA6GhhTxfX5N3XE/DQ27/384HQAei6RFClBZoGtX8MKrC 7Yv7N3BhwHVL9ykx6JC2bDm9TjMirCBFS8QvYBOAT5TsUKaPgoo4JhomVwqltLuYlAkX fxxhVeX1GMbMlqQTDjmAQAyPU5IB6UvXQcptcrB3dk/chgvhaFEvMrxqmYZ5/DW6LNNw UhP5Yltp5hlURJWWwXa8Su8Lu9VN5CyCqbk8Vt/prFod8nN77yUiXp4G/P3BU1Bf9pbI sn2LztYv1bnZo2v197uN3kAj6wBmEugKBdORNmDI9zgAoRTOD+5JARyEnwGSWIMwc0i0 vpmQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=Qhz3ZHCM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=DI27VjsD; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-38577-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id x15-20020ac85f0f000000b0042a2a01bd35si12634842qta.600.2024.01.25.04.27.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Jan 2024 04:27:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-38577-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=@arndb.de header.s=fm2 header.b=Qhz3ZHCM; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=DI27VjsD; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-38577-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-38577-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de 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 A37421C23CA9 for ; Thu, 25 Jan 2024 12:27:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1601746447; Thu, 25 Jan 2024 12:27:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="Qhz3ZHCM"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="DI27VjsD" Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (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 7CE6A1C69E; Thu, 25 Jan 2024 12:27:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=66.111.4.25 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706185634; cv=none; b=bxheK0zoy6+/GQ+5oCCpVZ9zDdYY0/3Ca1IBS0/C3hvH7uptapeK2fSf9Xayi+zWeyRHc+CYsnIELYRiFncPN5bRbTHDsYPj4PXo2dXMHO3evsWHCjLu6zwp0LPrQdXGvupP9cUNpmEcAatpBbu8YDkttF1l2Fk0PWnVri8kDN0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706185634; c=relaxed/simple; bh=wW002LqBW9IbuYi/opDK+aD4T+xvFlR1R51XeVtO4cQ=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=cvN3NZcufPzyb72/re+/+UL/zOxbGgwlHxS8EOkPqhuaO20FEkJQPtVKKtjbZJltmG8V6TybyKrebey+66YTtnFyvOcGJtqX4Hrbn5seCJdO7W+WKNL8he3sa0epHFljkoN5p9MdCFiFufzHP5aU7vYtXtJaBB+39Q4C8jsaxi4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=Qhz3ZHCM; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=DI27VjsD; arc=none smtp.client-ip=66.111.4.25 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 789225C0079; Thu, 25 Jan 2024 07:27:11 -0500 (EST) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Thu, 25 Jan 2024 07:27:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1706185631; x=1706272031; bh=by9e17p4Sb OQuMUvw9yQVjRsSkMsUr3SrHfJ/laHRbg=; b=Qhz3ZHCM0A2MCUj+5XfxRhJVO3 O2Ivz5XGXCxJd/BGx2BD0S6Dz9zUhxAk001fHtcPfbdXoIgRGiffEUPv4WQf1uCE 1yS3fMhW4XheQxgr/ktuz8VKrtRrh/inpkDdLyEwXem5HNL6ioijwf92eW/nNK3G TUEpCwQabLXMp/sbcOK4bZ4l29mjNItBZXJMms6Z/PHChXO5/luLzJDEkSXGsbbh RQncUjAGZIaJ0aPPlfnUxutpL8YyfcqunSQp5tNO3EL6jY8U/NWvsOH5oBpPWaQ1 fX1yYVuZTaMK6rXYRmtuMGgSnlb8c98bVtW09lwZ+eXrqWYl47l/zCpMqz7A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1706185631; x=1706272031; bh=by9e17p4SbOQuMUvw9yQVjRsSkMs Ur3SrHfJ/laHRbg=; b=DI27VjsDLadMVpQUkzwg04V8tTBEb6Xfbjm/Bs1CD+Yc fO6ul8hQgf7Xe86C5N8Wcr5/CMKgeMMxi/cb6I3bcQ6RHCRa6oIBRiRSvHA1xJgW A4pf1yE3Ko2mwJ+kQQSHuVCej/q0dFuzCC44FEpbSM/k66Ik65bTrcak57RYn1Qx bis+MfF9NlshGqjK84KSSHOMOcaU0THauJPhFuRWLOwPeYs7lm5BQ7rwUmctImGw pduXxxky5tQwpwl4POfNTW6mQmbdMR5mYG5r3YZxRb+meHirymyWLf64s8lq84VQ eYj7hLcH05B92V93iuYIyJjVn1WB2tTQm7ulMoSCtw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrvdelgedgudefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 7AA4CB6008D; Thu, 25 Jan 2024 07:27:10 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-119-ga8b98d1bd8-fm-20240108.001-ga8b98d1b Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <070574cb-8d7f-4fe7-9826-cec6110168ff@app.fastmail.com> In-Reply-To: <20240124-alice-mm-v1-2-d1abcec83c44@google.com> References: <20240124-alice-mm-v1-0-d1abcec83c44@google.com> <20240124-alice-mm-v1-2-d1abcec83c44@google.com> Date: Thu, 25 Jan 2024 13:26:50 +0100 From: "Arnd Bergmann" To: "Alice Ryhl" , "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" , "Alexander Viro" , "Andrew Morton" Cc: "Greg Kroah-Hartman" , =?UTF-8?Q?Arve_Hj=C3=B8nnev=C3=A5g?= , "Todd Kjos" , "Martijn Coenen" , "Joel Fernandes" , "Carlos Llamas" , "Suren Baghdasaryan" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org, "Christian Brauner" Subject: Re: [PATCH 2/3] rust: add typed accessors for userspace pointers Content-Type: text/plain On Wed, Jan 24, 2024, at 12:20, Alice Ryhl wrote: > +unsigned long > rust_helper_copy_from_user_unsafe_skip_check_object_size(void *to, > const void __user *from, unsigned long n) > +{ > + unsigned long res; > + > + might_fault(); > + instrument_copy_from_user_before(to, from, n); > + if (should_fail_usercopy()) > + return n; > + res = raw_copy_from_user(to, from, n); > + instrument_copy_from_user_after(to, from, n, res); > + return res; > +} > +EXPORT_SYMBOL_GPL(rust_helper_copy_from_user_unsafe_skip_check_object_size); > + > +unsigned long > rust_helper_copy_to_user_unsafe_skip_check_object_size(void __user *to, > const void *from, unsigned long n) > +{ > + might_fault(); > + if (should_fail_usercopy()) > + return n; > + instrument_copy_to_user(to, from, n); > + return raw_copy_to_user(to, from, n); > +} > +EXPORT_SYMBOL_GPL(rust_helper_copy_to_user_unsafe_skip_check_object_size); These functions are almost identical to the ones in lib/usercopy.c for !defined(INLINE_COPY_TO_USER). That version has an extra memset() after a partial copy_from_user(), and you probably want to have the same thing here for consistency. I think ideally we should only have one out-of-line copy of these two functions and have that one shared between rust and architectures that want the C version out of line as well. Arnd