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 X-Spam-Level: X-Spam-Status: No, score=-12.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6664C4346E for ; Tue, 29 Sep 2020 09:33:43 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 45E9D20848 for ; Tue, 29 Sep 2020 09:33:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CedBVAmP"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=armlinux.org.uk header.i=@armlinux.org.uk header.b="jvH1mFJY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 45E9D20848 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=armlinux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5Qv93Dwd6bQIH0YD2VNp5zy6REktYBwyuXmgS2zeN3U=; b=CedBVAmPBuc1vYBcz7Yt5i6hq +RfmszKkLGzfgtu6XOlFaPL1e10KQUDmYLjGQQuOLQd3l3CmubKS/FgqJU5jtDo25fjzBXpZE6swL f5XJVzrp0QlujHNT6nju51ZHSXB1UQagprF0vMWkuZblKFGB3nB7ekrRimrsOXBYVemP2V4buZnDk 8S/8a2DeHDS4piyqJU6Aua41FMpbr3nZ1sTL/TkiIebwN73HqYDa1AkYxt5xTfFDsCsk+9Xa1qRz/ auTDYmwIFLo+T9cxoaRmnmFp+99QkrbJ/Udg/IlSCb9AlORqxiYnSSrVP2BjZZaOcW4jxOMgv5Y6Z DIig2CACQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNBzV-0007Mo-Eh; Tue, 29 Sep 2020 09:32:09 +0000 Received: from pandora.armlinux.org.uk ([2001:4d48:ad52:32c8:5054:ff:fe00:142]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNBzS-0007Lr-58 for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2020 09:32:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=L/ey0FlBUomsvt5kEAZLeQIKu5I+g61yXXfzBNkxeGk=; b=jvH1mFJYsYNnNqIm93TQQQqJo 8tBlc6SGwARri9kMTW/zdTWx5Bmfu8czYgX5XmuCid9xFVFGLvqDBjBPyz9ymyFAX2Iyom3TBUORe WHZc1ertI0Ln6JT0o95SjtmA7oG8McodufGrfhtKQLaBd/k4QATD/qthhkDpmvnD2+McVLAXir4Nk qRaHk8sY1rpzZ1UeD+WKMN40pnBSRu1n+jqxCVxUuB5Nk3yIwagwxP7F+2l570O/DdL5sfdyfiCOg bBlYd+x/8/Td2Xs7HfvfNk+/kElzyJzP+9Fl+HNZHbyNpWT7rT/XUtfqfCIiY+EnUERfmG8uOcd/O Exnn/rVag==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:39726) by pandora.armlinux.org.uk with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kNBzM-0000vo-9A; Tue, 29 Sep 2020 10:32:00 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.92) (envelope-from ) id 1kNBzK-00010w-Gh; Tue, 29 Sep 2020 10:31:58 +0100 Date: Tue, 29 Sep 2020 10:31:58 +0100 From: Russell King - ARM Linux admin To: Christian Lamparter Subject: Re: [PATCH] arm: use mmap_write_(un)lock for copy_to_user Message-ID: <20200929093158.GC1551@shell.armlinux.org.uk> References: <20200926192854.22164-1-chunkeey@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200926192854.22164-1-chunkeey@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200929_053206_218599_84A57D71 X-CRM114-Status: GOOD ( 21.51 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Morton , Mike Rapoport , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sat, Sep 26, 2020 at 09:28:54PM +0200, Christian Lamparter wrote: > changes ARM's copy_to_user to use mmap_*write*_lock > variants. This is because the data is written to > user-space and not read. The "read" lock is there to ensure that the page tables are not changed (e.g. due to a page fault in another thread) while we are making changes to the page. It is a "read" lock because we can tolerate other threads reading the page tables and mm structures, but not making changes to those structures. This has nothing to do with whether we are reading or writing userspace. Therefore, your patch is incorrect. What problem are you seeing? > > Signed-off-by: Christian Lamparter > --- > arch/arm/lib/uaccess_with_memcpy.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c > index 106f83a5ea6d..7491c13fdf0e 100644 > --- a/arch/arm/lib/uaccess_with_memcpy.c > +++ b/arch/arm/lib/uaccess_with_memcpy.c > @@ -101,7 +101,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) > atomic = faulthandler_disabled(); > > if (!atomic) > - mmap_read_lock(current->mm); > + mmap_write_lock(current->mm); > while (n) { > pte_t *pte; > spinlock_t *ptl; > @@ -109,11 +109,11 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) > > while (!pin_page_for_write(to, &pte, &ptl)) { > if (!atomic) > - mmap_read_unlock(current->mm); > + mmap_write_unlock(current->mm); > if (__put_user(0, (char __user *)to)) > goto out; > if (!atomic) > - mmap_read_lock(current->mm); > + mmap_write_lock(current->mm); > } > > tocopy = (~(unsigned long)to & ~PAGE_MASK) + 1; > @@ -133,7 +133,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) > spin_unlock(ptl); > } > if (!atomic) > - mmap_read_unlock(current->mm); > + mmap_write_unlock(current->mm); > > out: > return n; > -- > 2.28.0 > > -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last! _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel