From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61ADEFF8875 for ; Wed, 29 Apr 2026 10:25:59 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4g5D3V05SWz2yD6; Wed, 29 Apr 2026 20:25:58 +1000 (AEST) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=95.215.58.189 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1777458357; cv=none; b=EXHq1RObub0E9HOaXwWKpgSdTlMOBY48W0kJf+v6P92jV8EKIjUSdQrWALXrD8fYLbe678ObzYN6xyPklkYqNQ7gMk++wGWl81lCrXsggDv435YP1W0VsqOYjRiAFYPjGMWqlsyLTkQTKzbSHbKJA+clokV6bbWMU9CdgeJQBbMqsuSMsVCa2v8yjyKyLqi67/lN5mQNA/a6dhY/G5WVTsum1Q7t8oiMn8CpCBVRVTJEWXaNCNqi5SCfumqf2OQRdL50ixF7l1zat10aJRe1FcG7QNWflfwPA6QzugZkSIl5iLs2Af4Zi+RkeP9QevSs2YpXvhOc0DdWKXybdzlDbg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1777458357; c=relaxed/relaxed; bh=0ubnPqyEuUH+bb9tWP9+TOUp+n6C5onOR58LCuBDEiw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EAxovUV39pdviWRMVEs3qPpb6vyBH5RR/I2twb+I4Vsmv5SwtrFpG8TAQzQTynrsyxpnnfw5bVOkjxLKiT+XvYY1KXvb3FMCgsOfSsFRGkj3R48oSXSI70dzZ/bgGfzF9stNhpjXcHvvv3DnoZ0jWoCXMq0c5bNI3s3RhnDRs7i1ClY5KVEp9dGy/V02xqFkENMHDPNpGVKfvSNVXfo4oGGzYpHdLS91a6X/N5LIyk5uCo/9Et4ejmNRzyt0x3gefyvx8dF7j2w8IVx74OZ4HqJ8W8iCeECeoxASV+gqMpClxWTR5md1+obAICSFAPWh6+Ikqe6m1FK/AJSeg1FuVA== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=syDuJ2eb; dkim-atps=neutral; spf=pass (client-ip=95.215.58.189; helo=out-189.mta1.migadu.com; envelope-from=usama.arif@linux.dev; receiver=lists.ozlabs.org) smtp.mailfrom=linux.dev Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=syDuJ2eb; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.dev (client-ip=95.215.58.189; helo=out-189.mta1.migadu.com; envelope-from=usama.arif@linux.dev; receiver=lists.ozlabs.org) Received: from out-189.mta1.migadu.com (out-189.mta1.migadu.com [95.215.58.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4g5D3R1cMCz2xSB for ; Wed, 29 Apr 2026 20:25:54 +1000 (AEST) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777458333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0ubnPqyEuUH+bb9tWP9+TOUp+n6C5onOR58LCuBDEiw=; b=syDuJ2ebh9z2sjffREH58o0aT6Ajjew8W5I8ReEUtvp2EQkdghmYv8iT9JcU1iX87oMIbX D+xmbMoFNHgWVKDoL6XEe6kPFjJgAeA5FQrv1tK/6uUbSyjmFqItMdxDS/n3eJA5ihtrWC pDy1LXDxeyfrSgRVjezaD0bM6Fa+Scc= From: Usama Arif To: "Christophe Leroy (CS GROUP)" Cc: Usama Arif , Yury Norov , Andrew Morton , Linus Torvalds , David Laight , Thomas Gleixner , linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, kvm@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, dmaengine@vger.kernel.org, linux-efi@vger.kernel.org, linux-fsi@lists.ozlabs.org, amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, linux-wpan@vger.kernel.org, netdev@vger.kernel.org, linux-wireless@vger.kernel.org, linux-spi@vger.kernel.org, linux-media@vger.kernel.org, linux-staging@lists.linux.dev, linux-serial@vger.kernel.org, linux-usb@vger.kernel.org, xen-devel@lists.xenproject.org, linux-fsdevel@vger.kernel.org, ocfs2-devel@lists.linux.dev, bpf@vger.kernel.org, kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-x25@vger.kernel.org, rust-for-linux@vger.kernel.org, linux-sound@vger.kernel.org, sound-open-firmware@alsa-project.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-openrisc@vger.kernel.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, linux-arch@vger.kernel.org Subject: Re: [RFC PATCH v1 7/9] x86: Add unsafe_copy_from_user() Date: Wed, 29 Apr 2026 03:25:19 -0700 Message-ID: <20260429102520.1617327-1-usama.arif@linux.dev> In-Reply-To: <0ee46bb228d97163fbdc14f2a7c52b93d8bc34ce.1777306795.git.chleroy@kernel.org> References: X-Mailing-List: linuxppc-dev@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Archive: , List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT On Mon, 27 Apr 2026 19:13:48 +0200 "Christophe Leroy (CS GROUP)" wrote: > At the time being, x86 and arm64 are missing unsafe_copy_from_user(). > > Add it. > > Signed-off-by: Christophe Leroy (CS GROUP) > --- > arch/x86/include/asm/uaccess.h | 29 ++++++++++++++++++++++++----- > 1 file changed, 24 insertions(+), 5 deletions(-) > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 3a0dd3c2b233..10c458ffa399 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -598,7 +598,7 @@ _label: \ > * We want the unsafe accessors to always be inlined and use > * the error labels - thus the macro games. > */ > -#define unsafe_copy_loop(dst, src, len, type, label) \ > +#define unsafe_put_loop(dst, src, len, type, label) \ > while (len >= sizeof(type)) { \ > unsafe_put_user(*(type *)(src),(type __user *)(dst),label); \ > dst += sizeof(type); \ > @@ -611,10 +611,29 @@ do { \ > char __user *__ucu_dst = (_dst); \ > const char *__ucu_src = (_src); \ > size_t __ucu_len = (_len); \ > - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u64, label); \ > - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u32, label); \ > - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u16, label); \ > - unsafe_copy_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \ > + unsafe_put_loop(__ucu_dst, __ucu_src, __ucu_len, u64, label); \ > + unsafe_put_loop(__ucu_dst, __ucu_src, __ucu_len, u32, label); \ > + unsafe_put_loop(__ucu_dst, __ucu_src, __ucu_len, u16, label); \ > + unsafe_put_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \ > +} while (0) > + > +#define unsafe_get_loop(dst, src, len, type, label) \ > + while (len >= sizeof(type)) { \ > + unsafe_get_user(*(type __user *)(src),(type *)(dst),label); \ Hi, Just wanted to check if src and dst need to be swapped? Same for arm64 patch. > + dst += sizeof(type); \ > + src += sizeof(type); \ > + len -= sizeof(type); \ > + } > + > +#define unsafe_copy_from_user(_dst,_src,_len,label) \ > +do { \ > + char *__ucu_dst = (_dst); \ > + const char __user *__ucu_src = (_src); \ > + size_t __ucu_len = (_len); \ > + unsafe_get_loop(__ucu_dst, __ucu_src, __ucu_len, u64, label); \ > + unsafe_get_loop(__ucu_dst, __ucu_src, __ucu_len, u32, label); \ > + unsafe_get_loop(__ucu_dst, __ucu_src, __ucu_len, u16, label); \ > + unsafe_get_loop(__ucu_dst, __ucu_src, __ucu_len, u8, label); \ > } while (0) > > #ifdef CONFIG_CC_HAS_ASM_GOTO_OUTPUT > -- > 2.49.0 > >