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=-10.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 BA8F0C4346E for ; Tue, 29 Sep 2020 09:28:20 +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 4DECE20774 for ; Tue, 29 Sep 2020 09:28:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="CM2oQauF"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="IA4lRI4D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4DECE20774 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org 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=tue1m6xqyUOSHifALQmmu1JP9ZUcrxH8mITFVNQETIg=; b=CM2oQauFKVE5cFjT09UNVORSO Eir+FRQxlFbBzi/9DQ4gPiSrbGFdyt63E5SAcHRbgQTNdM0v7yo3mXBbjjTZeDvIBBfLHmX9v2m8r ZbjVaVxRa5QFIsNABFunO+SsaccaRUgFA6Hbi1lNu7eZsGyJlAzV9TxgCuEu7amTbNcKv1bmv6S2h qRgrDM70VwTZ/qGKrYpaqO0Jk0sCwFAm4qF+KVFnAr/9MS2HMDCoITrnsLlvf+RA3kpgFdspmVjIl xXPNX/jur+/l9gL3Dxo8iFBnyyOhTef6XPnftM1eHw3k1EB+nficJtZi2H8cu64CysMYuNZ4iwYag 6/yVw2dYA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNBuc-0006EH-0D; Tue, 29 Sep 2020 09:27:06 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kNBuY-0006DI-Vm for linux-arm-kernel@lists.infradead.org; Tue, 29 Sep 2020 09:27:03 +0000 Received: from kernel.org (unknown [87.71.73.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id F21A02076B; Tue, 29 Sep 2020 09:26:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601371622; bh=1EvhxRX3PHAQ0ABnkhO2LZdvdxw3ITVDRlN5JpwksaI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IA4lRI4DHcRg66meNmj1BYJMnJbSKlNTxkEIidc+aTXi5Ei8fiznn5K1iNEU4B3sG RjX4XxSXI9zhhU9//HI+yVb+cffgXdUdX892cLjc3aK/WYWtuxGKZKqItuF1Aro3uG VGV4Ai5k4VpbZ4YRt1sWIh9tfCyLhJjQzczs5DUk= Date: Tue, 29 Sep 2020 12:26:51 +0300 From: Mike Rapoport To: Christian Lamparter Subject: Re: [PATCH] arm: use mmap_write_(un)lock for copy_to_user Message-ID: <20200929092651.GD2142832@kernel.org> References: <20200926192854.22164-1-chunkeey@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20200926192854.22164-1-chunkeey@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200929_052703_109939_7841B206 X-CRM114-Status: GOOD ( 19.31 ) 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 , Russell King , 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 mmap lock protects internals of 'struct mm_struct' and they do not change when the data is copied regardless of its direction. > 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 > -- Sincerely yours, Mike. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel