{"id":2229043,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2229043/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-um/patch/c73b90236f2810edd47c84edd2a8d8e8e0c816da.1777306795.git.chleroy@kernel.org/","project":{"id":60,"url":"http://patchwork.ozlabs.org/api/1.1/projects/60/?format=json","name":"User-mode Linux Development","link_name":"linux-um","list_id":"linux-um.lists.infradead.org","list_email":"linux-um@lists.infradead.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<c73b90236f2810edd47c84edd2a8d8e8e0c816da.1777306795.git.chleroy@kernel.org>","date":"2026-04-27T17:13:45","name":"[RFC,v1,4/9] uaccess: Introduce copy_{to/from}_user_partial()","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"63ebd577e3047f5527cbdb6e45e9aeef7a3420cd","submitter":{"id":92089,"url":"http://patchwork.ozlabs.org/api/1.1/people/92089/?format=json","name":"Christophe Leroy (CS GROUP)","email":"chleroy@kernel.org"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-um/patch/c73b90236f2810edd47c84edd2a8d8e8e0c816da.1777306795.git.chleroy@kernel.org/mbox/","series":[{"id":501693,"url":"http://patchwork.ozlabs.org/api/1.1/series/501693/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-um/list/?series=501693","date":"2026-04-27T17:13:41","name":"uaccess: Convert small fixed size copy_{to/from}_user() to scoped user access","version":1,"mbox":"http://patchwork.ozlabs.org/series/501693/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2229043/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2229043/checks/","tags":{},"headers":{"Return-Path":"\n <linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qupMSoKa;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=JDwlcHyn;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g49JJ1hqbz1xvV\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 28 Apr 2026 03:18:24 +1000 (AEST)","from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHPbC-0000000HR72-2HyC;\n\tMon, 27 Apr 2026 17:18:22 +0000","from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25])\n\tby bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux))\n\tid 1wHPb7-0000000HR41-48rJ;\n\tMon, 27 Apr 2026 17:18:19 +0000","from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58])\n\tby sea.source.kernel.org (Postfix) with ESMTP id 8B93C440C2;\n\tMon, 27 Apr 2026 17:18:17 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 08C06C2BCF4;\n\tMon, 27 Apr 2026 17:17:56 +0000 (UTC)"],"DKIM-Signature":["v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help\n\t:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding:\n\tMIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:\n\tReply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=sOGbn9OoG8rBGqzI2kLVy+02fyWRJuxPwbq3dZ0vyfI=; b=qupMSoKaU0Bjd7i4aHLO6AYyTP\n\tQTHrFUyi4KngvR3PvoxL90PueiituFMG8NoszyrC9UKl2IqPqUxmMenJOVCSeRkskiB5+Jacx0Vq1\n\tpAC/wgL2DjdWTe1cD3kpH15aLNRDQqGqr+Mk4YxjjtMdM4so1fvul+6own3bXDEf7iNSSNp9UAbSh\n\tBMT3LaXhLdgZxaogDr8P+nPyUD5ab1BQqEnWcALCa+vTC9tWDfwYzgfTEQp07EZHye4NNz+VYcg51\n\tOaL28YUWK4MNrVQ+fAI6l4KfYOdnUH6L88nP/PtXKUYCTpKuINl0giOkEscpZoR+Tz6wRB17FtgFU\n\tXQLgn50A==;","v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1777310297;\n\tbh=G/2eQ9TI5TAejE5IgsfdvVcfACCawPpecEdM1VXM32k=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=JDwlcHynPBKJgZEQOCWtilxNz5OJTbEC9ImCjJuQT3RnOoZjD4+90hMORF2q1smV0\n\t ZZwStmTz2ZWfCFTglmd/E7DTmKQiqUkyq6DoW4QkOcmP8LtfpYhN9V4ZMaLV1xjKUX\n\t qf/gxqJdT3gAPMXuYRhHcRDH0KM3YGUgvPXpdKncm5DePPHjb0VOG6buq4s8MreRM+\n\t EZo8pRxSQAzQ5kujjD1AkNCv3dgeUm7ZrfC1oOr8cnbPHFYMiYdejiO8B5iigWhrca\n\t 1OgKQbcauQ7QAB8qeF6Zf8CM71cpuIXWBUm7GSS+m87r+rFbtJTWOdD0Mn8qIs0Vfn\n\t 3JDYXNLvVgu3g=="],"From":"\"Christophe Leroy (CS GROUP)\" <chleroy@kernel.org>","To":"Yury Norov <ynorov@nvidia.com>,\n\tAndrew Morton <akpm@linux-foundation.org>,\n\tLinus Torvalds <torvalds@linux-foundation.org>,\n\tDavid Laight <david.laight.linux@gmail.com>,\n\tThomas Gleixner <tglx@linutronix.de>","Cc":"\"Christophe Leroy (CS GROUP)\" <chleroy@kernel.org>,\n\tlinux-alpha@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org,\n\tlinux-snps-arc@lists.infradead.org,\n\tlinux-arm-kernel@lists.infradead.org,\n\tlinux-mips@vger.kernel.org,\n\tlinuxppc-dev@lists.ozlabs.org,\n\tkvm@vger.kernel.org,\n\tlinux-riscv@lists.infradead.org,\n\tlinux-s390@vger.kernel.org,\n\tsparclinux@vger.kernel.org,\n\tlinux-um@lists.infradead.org,\n\tdmaengine@vger.kernel.org,\n\tlinux-efi@vger.kernel.org,\n\tlinux-fsi@lists.ozlabs.org,\n\tamd-gfx@lists.freedesktop.org,\n\tdri-devel@lists.freedesktop.org,\n\tintel-gfx@lists.freedesktop.org,\n\tlinux-wpan@vger.kernel.org,\n\tnetdev@vger.kernel.org,\n\tlinux-wireless@vger.kernel.org,\n\tlinux-spi@vger.kernel.org,\n\tlinux-media@vger.kernel.org,\n\tlinux-staging@lists.linux.dev,\n\tlinux-serial@vger.kernel.org,\n\tlinux-usb@vger.kernel.org,\n\txen-devel@lists.xenproject.org,\n\tlinux-fsdevel@vger.kernel.org,\n\tocfs2-devel@lists.linux.dev,\n\tbpf@vger.kernel.org,\n\tkasan-dev@googlegroups.com,\n\tlinux-mm@kvack.org,\n\tlinux-x25@vger.kernel.org,\n\trust-for-linux@vger.kernel.org,\n\tlinux-sound@vger.kernel.org,\n\tsound-open-firmware@alsa-project.org,\n\tlinux-csky@vger.kernel.org,\n\tlinux-hexagon@vger.kernel.org,\n\tloongarch@lists.linux.dev,\n\tlinux-m68k@lists.linux-m68k.org,\n\tlinux-openrisc@vger.kernel.org,\n\tlinux-parisc@vger.kernel.org,\n\tlinux-sh@vger.kernel.org,\n\tlinux-arch@vger.kernel.org","Subject":"[RFC PATCH v1 4/9] uaccess: Introduce copy_{to/from}_user_partial()","Date":"Mon, 27 Apr 2026 19:13:45 +0200","Message-ID":"\n <c73b90236f2810edd47c84edd2a8d8e8e0c816da.1777306795.git.chleroy@kernel.org>","X-Mailer":"git-send-email 2.49.0","In-Reply-To":"<cover.1777306795.git.chleroy@kernel.org>","References":"<cover.1777306795.git.chleroy@kernel.org>","MIME-Version":"1.0","X-Developer-Signature":"v=1; a=openpgp-sha256; l=1585; i=chleroy@kernel.org;\n h=from:subject:message-id; bh=G/2eQ9TI5TAejE5IgsfdvVcfACCawPpecEdM1VXM32k=;\n b=owGbwMvMwCV2d0KB2p7V54MZT6slMWS+nxmjMKmwhcOl/KmCyQK3t3e2vTXauaOc++38fue5J\n 1/fnLd3d0cpC4MYF4OsmCLL8f/cu2Z0fUnNn7pLH2YOKxPIEAYuTgGYyD5HRoZnIqUtqi/uzJzx\n /elrrqTduXsuSM05kFXcMu1CQyFnzPFOhv/RJewtZeu89EsObX+ieXizf2Xo8RNCJwMOumbxCC5\n Mr+EBAA==","X-Developer-Key":"i=chleroy@kernel.org; a=openpgp;\n fpr=10FFE6F8B390DE17ACC2632368A92FEB01B8DD78","Content-Transfer-Encoding":"8bit","X-CRM114-Version":"20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 ","X-CRM114-CacheID":"sfid-20260427_101818_067118_086FD715 ","X-CRM114-Status":"GOOD (  13.07  )","X-Spam-Score":"-2.1 (--)","X-Spam-Report":"Spam detection software,\n running on the system \"bombadil.infradead.org\",\n has NOT identified this incoming email as spam.  The original\n message has been attached to this so you can view it or label\n similar future email.  If you have any questions, see\n the administrator of that system for details.\n Content preview:  Today there are approximately 3000 calls for copy_to_user()\n    and 3000 calls to copy_from_user(). The majority of callers of\n copy_{to/from}_user()\n    don't care about the return value, they only check whether it is 0 or not,\n    and when it is not 0 they handle it as a -EACCES.\n Content analysis details:   (-2.1 points, 5.0 required)\n  pts rule name              description\n ---- ----------------------\n --------------------------------------------------\n -0.0 SPF_PASS               SPF: sender matches SPF record\n  0.0 SPF_HELO_NONE          SPF: HELO does not publish an SPF Record\n -0.1 DKIM_VALID_EF          Message has a valid DKIM or DK signature from\n                             envelope-from domain\n -0.1 DKIM_VALID_AU          Message has a valid DKIM or DK signature from\n author's\n                             domain\n -0.1 DKIM_VALID             Message has at least one valid DKIM or DK\n signature\n  0.1 DKIM_SIGNED            Message has a DKIM or DK signature,\n not necessarily valid\n -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%\n                             [score: 0.0000]\n -0.0 DKIMWL_WL_HIGH         DKIMwl.org - High trust sender","X-BeenThere":"linux-um@lists.infradead.org","X-Mailman-Version":"2.1.34","Precedence":"list","List-Id":"<linux-um.lists.infradead.org>","List-Unsubscribe":"<http://lists.infradead.org/mailman/options/linux-um>,\n <mailto:linux-um-request@lists.infradead.org?subject=unsubscribe>","List-Archive":"<http://lists.infradead.org/pipermail/linux-um/>","List-Post":"<mailto:linux-um@lists.infradead.org>","List-Help":"<mailto:linux-um-request@lists.infradead.org?subject=help>","List-Subscribe":"<http://lists.infradead.org/mailman/listinfo/linux-um>,\n <mailto:linux-um-request@lists.infradead.org?subject=subscribe>","Sender":"\"linux-um\" <linux-um-bounces@lists.infradead.org>","Errors-To":"linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"},"content":"Today there are approximately 3000 calls for copy_to_user() and\n3000 calls to copy_from_user().\n\nThe majority of callers of copy_{to/from}_user() don't care about the\nreturn value, they only check whether it is 0 or not, and when it is\nnot 0 they handle it as a -EACCES.\n\nIn order to allow better optimisation of copy_{to/from}_user() when\nthe size of the copy is known at build time, create new fonctions\nnamed copy_{to/from}_user_partial() to be used by the few callers\nthat are interested in partial copies and need to now how many\nbytes remain at the end of the copy.\n\nFor the time being it is just the same as copy_{to/from}_user().\n\nSigned-off-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>\n---\n include/linux/uaccess.h | 4 ++++\n 1 file changed, 4 insertions(+)","diff":"diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h\nindex bd1201c81d94..2d37173782b3 100644\n--- a/include/linux/uaccess.h\n+++ b/include/linux/uaccess.h\n@@ -221,6 +221,8 @@ copy_from_user(void *to, const void __user *from, unsigned long n)\n \t\treturn _inline_copy_from_user(to, from, n);\n }\n \n+#define copy_from_user_partial copy_from_user\n+\n static __always_inline unsigned long __must_check\n copy_to_user(void __user *to, const void *from, unsigned long n)\n {\n@@ -233,6 +235,8 @@ copy_to_user(void __user *to, const void *from, unsigned long n)\n \t\treturn _inline_copy_to_user(to, from, n);\n }\n \n+#define copy_to_user_partial copy_to_user\n+\n #ifndef copy_mc_to_kernel\n /*\n  * Without arch opt-in this generic copy_mc_to_kernel() will not handle\n","prefixes":["RFC","v1","4/9"]}