From patchwork Sat Sep 26 19:28:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Lamparter X-Patchwork-Id: 11801631 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 3D3C76CA for ; Sat, 26 Sep 2020 19:29:22 +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 0294621D95 for ; Sat, 26 Sep 2020 19:29:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cXzd1y31"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K5QYpaw1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0294621D95 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=DqX6e4m7VgV7Q4WBckjJ8j2Y2585vmX9nU+VMB7SKQI=; b=cXzd1y31RKGi38DlLn0qfSTiov SVGAB9J4VFnu+L7iMKm6suLO1TdlUV8C9yF1VXyMQJoCt3Tp6XEpSr5HA+tpx7yuV+FK+S4M6ozNq LknralDTmAgytX7JxpDRNyXpwrBtiIiBV4Am4UzOAx6lob43TGyXVHCdIvUtOOuanTH0awgAOoBPH 2znmwm2ZCEP88EWZnqqWj+EzrBhJEML78VB6rhM6TgVHZ861NfNDvwCN7gv6jWhe6mvbjvojuYN9i SFw1oNkdUlRwFiFZ7rxzH0Jr9W2jMvVYyFv+qKVQenP4WsowmyUrpFUCEzE13zPM2mMh6vu87SUeU 2Ra5F7ow==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMFsV-0005Z7-3T; Sat, 26 Sep 2020 19:29:03 +0000 Received: from mail-ed1-x543.google.com ([2a00:1450:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kMFsS-0005Xv-8Q for linux-arm-kernel@lists.infradead.org; Sat, 26 Sep 2020 19:29:01 +0000 Received: by mail-ed1-x543.google.com with SMTP id j2so5910906eds.9 for ; Sat, 26 Sep 2020 12:28:57 -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=cMLipTk4OVO5SWbCNnp93TKaCYZi2Q6qJhNW4TcwFAM=; b=K5QYpaw1yF9nOYnao839OmyiEAisi07X6/RhOi5tagSxlR8gUx7vXgHFr6xC541dxE OQ3lLZ+kW0OvUt4ivi830m8YZ5itet6vlhiFiTSeglTPmmlfJjR6TDXIkbZD2tdPy/au VWNOJ0IubPU7C6++ncZyyaCW0gcLJFrqTj7aDo47Rd+rzHqvEFFGbcq0Zecnj7/SRg9k NSoqOkQTPO3WHDnxv+TIvnI1/0JjoJnWrR53mvwDa3r2uDslRyRzh2j+afqmX7O1rcHr tDW2mWBHgY5LAMRcOKXmtvK3nFBCWznNgb0WBt10nPwT+ZxGOPLKHUGIzpUw2myAz/VF LhIQ== 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=cMLipTk4OVO5SWbCNnp93TKaCYZi2Q6qJhNW4TcwFAM=; b=ndGh6iaS4CV9X2pAm2wU+x9HWtpgXsctR8mRr10Ujj3Z9Y1oLeBQIPBZT6/08BZIdv Em+vSW7PodaXYdOpctpKKa3BWcFdPm69AXkcTt8KN1qzgIZ/UStt3+ZG8P/VELqlSoe7 eFWbZNqRX/y35IJ2Zf2w8w0q6brgkoomTNwj1TWCZlaqMGHa/MmqEOJzzT+yPg/g8Mj2 iQdztaKEZlIsXD2CGIVEkr4T6+DgkRHhPC4qoVeN8UvEStVrStQWduDKE3pHzdqon3nO rRUESYNozTLTOT6h7rQdA2GuSt9nsGUjg3s45MJFttfgZvWn03IHKSC0h38PzRSVjMyr Qrjw== X-Gm-Message-State: AOAM532ogwdqN3BmFE4PH+b5mIKm/N8mUV4oLKZOLWZumEHhv0lUbY5T sEkOLJkq3mKsDJHDm6JJcZBW76EPpxs= X-Google-Smtp-Source: ABdhPJwdInYWEwd5BQzUg/rgt/Zid+yb9kyH4dpFHIG/j+hqWPs1ZOUWgIb8jHZw2LXi8X47mX6T7Q== X-Received: by 2002:a05:6402:644:: with SMTP id u4mr7795633edx.182.1601148536208; Sat, 26 Sep 2020 12:28:56 -0700 (PDT) Received: from debian64.daheim (pd9e298b1.dip0.t-ipconnect.de. [217.226.152.177]) by smtp.gmail.com with ESMTPSA id g24sm5119705edy.51.2020.09.26.12.28.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 26 Sep 2020 12:28:55 -0700 (PDT) Received: from chuck by debian64.daheim with local (Exim 4.94) (envelope-from ) id 1kMFsM-0005mD-Pi; Sat, 26 Sep 2020 21:28:54 +0200 From: Christian Lamparter To: linux-arm-kernel@lists.infradead.org, Russell King Subject: [PATCH] arm: use mmap_write_(un)lock for copy_to_user Date: Sat, 26 Sep 2020 21:28:54 +0200 Message-Id: <20200926192854.22164-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-20200926_152900_328958_D4A3443B X-CRM114-Status: GOOD ( 12.02 ) 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:543 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_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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. 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;