From patchwork Mon Sep 7 22:17:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 11762359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EAFCD138E for ; Mon, 7 Sep 2020 22:17:52 +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 872C0215A4 for ; Mon, 7 Sep 2020 22:17:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zsVNOhve"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BsY8kiwv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 872C0215A4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.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:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=14Qvk9zMOC5fiY28GdbkXbZUH0fxVjqKZZd1QPhwjvM=; b=zsVNOhveD05S1WOnizjodzGqyF ricEus5++EQ9kKEMbri2LjblM8mFhri7si44zDrc/HkGLc2LJwaItJGGjugeVSmaThnAqMReh5OsS uXdzuIvwfsT54ZlJKKCYk0htgHkafFpfdQbaxdQkKNm2tqp91O51lTNPWHhKvkAgt5mnnBJqgoQt+ SQay48VjOWatWZjOaSbDqNRltJBGtKB73FrqhFef93GBWb+9dfD/cCX8i4iVlaLqkEWRFRs6xOtSU XqzAUSCFyLWD0fRKOtCdNItbGp2fHGVPFcxxalMmBYtuSl+O004Glc7e5Xp5Cf3BJSoUIHFkhjxSv mH6SMt4g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFPS5-0001bm-UU; Mon, 07 Sep 2020 22:17:30 +0000 Received: from mail-wm1-x344.google.com ([2a00:1450:4864:20::344]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kFPS2-0001bL-Q1 for linux-arm-kernel@lists.infradead.org; Mon, 07 Sep 2020 22:17:27 +0000 Received: by mail-wm1-x344.google.com with SMTP id q9so15512328wmj.2 for ; Mon, 07 Sep 2020 15:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=i3R8NJJafuHPoFW5yVGtr5Bt5WcMjbYSaDyUZtKYeqI=; b=BsY8kiwv/FrBRv01wrhQOZZme8PuN+M2b6oLBDWnCUVg947FWFnKwIr4BMkQwUeykD NWwpDlNeNg+Ly3GyJzJabxbE3u/oChRtEpXuE3FDNIJrdM/ivAJZ4GsJqNmosBJ0N839 5x1mUsOpbRxwJ19Ddc8G4gUMoAQWom9j8AtAFmTBpyNtf4xt5zfEqXZRPm2xpcIEktap tpIo56jOHAMiagf538n515+28g9Pg/G9vA0XdmEJyMRVZMkhJtExEn8BVPdsn3CB4+dc FbCbZB8tZNaYkkHT5z2fDLGhUEG0QnWlzepuJiuiATay4+tvuMD7lKfG6amzxMbPvx5V CrpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=i3R8NJJafuHPoFW5yVGtr5Bt5WcMjbYSaDyUZtKYeqI=; b=F42hxe7py0JceucuU5RjiUEWnkuYNsL2HRc5X93LRq+cYGNOFVFymlLg9a3xudjVt+ j3mUKxFG6H4BFfprY0kMF0eKTivElQDd6XnUVD/gACeVVK4WOLHqXSXG73QjNjVzLEQN 4dXbzlx2CgVv/9xdvAy3uqyieuDSjO3DVvykHuQ8QQYfmwH03DstipvmbH6Mi57nO3W8 r4GsibAI63U7NLgpR8iKp8bNBfpFkbO/ybLPIv3O+WYsOzD2NsgYo9FGUA2EeSfGT1qT 0/3jrg/hiQGMmJRJU+LyGZaiqA2gVGS/zpNytWNLC5n9Y5NcMPxAwsartA8nw4M3lwo5 9PXg== X-Gm-Message-State: AOAM533QT+WMt4rX2BknNG2eRB+NDqzTJRaYbljl/pyNTE/pfaExvWSs CYW079Wy51llMfD9VybTbFSEZUHXijA= X-Google-Smtp-Source: ABdhPJzZ1OwXXWdR0R/BqeYdLPkjqXtofcOBgiy4rGNJTmzMBRNLQurxxMGamfVJAjTqi6fW1/5/jw== X-Received: by 2002:a7b:c3da:: with SMTP id t26mr1223658wmj.23.1599517044517; Mon, 07 Sep 2020 15:17:24 -0700 (PDT) Received: from blech.mobile (x4dbda00f.dyn.telefonica.de. [77.189.160.15]) by smtp.gmail.com with ESMTPSA id l16sm7128071wrb.70.2020.09.07.15.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Sep 2020 15:17:24 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by blech.mobile (Postfix) with ESMTP id 5ACE62613EB; Tue, 8 Sep 2020 00:17:23 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at blech.mobile Received: from blech.mobile ([127.0.0.1]) by localhost (blech.mobile [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id fGnTPAW74XHD; Tue, 8 Sep 2020 00:17:08 +0200 (CEST) Received: by blech.mobile (Postfix, from userid 1000) id 36578264E50; Tue, 8 Sep 2020 00:17:08 +0200 (CEST) From: Christian Lamparter To: linux-arm-kernel@lists.infradead.org, Russell King Subject: [RFC PATCH] arm: use mmap_write_(un)lock for copy_to_user Date: Tue, 8 Sep 2020 00:17:04 +0200 Message-Id: <20200907221704.38939-1-chunkeey@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200907_181726_866234_2D9EF50F X-CRM114-Status: GOOD ( 13.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:344 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [chunkeey[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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 , Chris Blake , Mike Rapoport , Christian Lamparter Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The way I understand this, the copy_to_user would require the use of the mmap_*write*_lock variants, since this functions writes to the user space pages? Cc: Chris Blake 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;