From patchwork Mon Feb 26 08:19:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10241563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 957C560386 for ; Mon, 26 Feb 2018 08:34:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 80B3B2998E for ; Mon, 26 Feb 2018 08:34:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7561629BFC; Mon, 26 Feb 2018 08:34:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ED7762998E for ; Mon, 26 Feb 2018 08:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=c5bUeyB/TRQ/xoQ9yi6l91CPSE4VvZVvGmx064oEPy0=; b=QgyOvB9Qlwnt4j HpBTXue+JuT1a8kCnNgSU5jd/1cOs/CT5zjmH4ZoIryKWE05h2iVE6ENREoRdOyG8BzIESa0jlzTo zDxqtU9v9pwlpmI1xNUcNABLmW7bhtxHSiJXzfhA8AKblqsig8pBAiKk/PrAULdEPbIL57pmnjn88 a9U+oHsyutZNf4/vsXOSUUJdqv+K8nRRWnvOWB89gsoF0wuY/ik3al4FVoxzjssXwzsybjoAV+kRs 7rwrRvhcDC4Ft//0v90qTfndX5JDp8LvMBbGPRF2YdqRaycIXpyUvekTu4P3LdopviLj72rdo3MYz YW5PH8ThDL1luRotlU/w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqEEx-0001ha-Dk; Mon, 26 Feb 2018 08:34:31 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqE3w-00015U-EA for linux-arm-kernel@lists.infradead.org; Mon, 26 Feb 2018 08:23:54 +0000 Received: by mail-pg0-x243.google.com with SMTP id y26so5910874pgv.4 for ; Mon, 26 Feb 2018 00:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=iAPTv5jlMzw6ovOzicmoLxGXCxHRzs8GBzIryr4d66U=; b=YBfQoz1u8brYY/frdZ/VdSuZzj7DLeGfREeI7i8Y/sPfBRTyFDQkAYxMUYrpw5GqyE q/eRL1rg0vsXX4DYVO0U0sS0hXDilH7xHSOtyHiWOMZvU/MdVm2yzd8DL9U5u2hA6/cC wD0iDLuVRmtMUiXpjvyxmzBZNSeq/tOrGj+fY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=iAPTv5jlMzw6ovOzicmoLxGXCxHRzs8GBzIryr4d66U=; b=izLunri8YJUkchI3Q5suO7trkhzmEJQvVbv4VThgx7dRxkEP0i3QjdQoi8lZ4FAWPb /Vx4sbDjYQDH3ljt8mGz7rFNNZXrIrtWIM/w3OAUjXq2cbzEjsPGI9b1Sts141y0IwYN KGyyRkwVTbQIiyR/gSJzMoc87pRLbwBGiRtl9XfAfznPjA7Tik3uqVrSnIIjUjsxqK+D x0w7yvEjr9JLRl0IwD/B9g9fHjvMYfLeUBtvkQCjR11eOLTafRewMv+2ruN3yRWvyuZS SRE7C4yfD4NQoR61lyPDu9xPDpxajUYIubXp1oQl5TSManiSwc2iZU/b4mZx19OdJIFU YDbA== X-Gm-Message-State: APf1xPAqNBpcYc7/eGQ5hHr1KND6GOgLbvj8gODwLWdTBNEGdoaGfSEj E2ICY6Rlbc/f24/gSTQqNiE4xA== X-Google-Smtp-Source: AH8x226I5xt8ghK4gbzXXuEUBbmSKfcDY2Ya8JDYEDjkHrBYuYS4TCfAmw4uVJEGd3TWLI3OSfKnFw== X-Received: by 10.99.125.92 with SMTP id m28mr7923145pgn.257.1519633377354; Mon, 26 Feb 2018 00:22:57 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.22.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:22:56 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 15/52] arm64: uaccess: Mask __user pointers for __arch_{clear, copy_*}_user Date: Mon, 26 Feb 2018 16:19:49 +0800 Message-Id: <1519633227-29832-16-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_002309_267349_36474D6C X-CRM114-Status: GOOD ( 12.84 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Will Deacon Rewritting from commit f71c2ffcb20d upstream. On LTS 4.9, there has no raw_copy_from/to_user, neither __copy_user_flushcache, and it isn't good idead to pick up them. The following is origin commit log, that's also applicable for the new patch. Like we've done for get_user and put_user, ensure that user pointers are masked before invoking the underlying __arch_{clear,copy_*}_user operations. Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Alex Shi --- arch/arm64/include/asm/uaccess.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index ffa4e39..fbf4ce4 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -357,14 +357,14 @@ static inline unsigned long __must_check __copy_from_user(void *to, const void _ { kasan_check_write(to, n); check_object_size(to, n, false); - return __arch_copy_from_user(to, from, n); + return __arch_copy_from_user(to, __uaccess_mask_ptr(from), n); } static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n) { kasan_check_read(from, n); check_object_size(from, n, true); - return __arch_copy_to_user(to, from, n); + return __arch_copy_to_user(__uaccess_mask_ptr(to), from, n); } static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n) @@ -374,7 +374,7 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u check_object_size(to, n, false); if (access_ok(VERIFY_READ, from, n)) { - res = __arch_copy_from_user(to, from, n); + res = __arch_copy_from_user(to, __uaccess_mask_ptr(from), n); } if (unlikely(res)) memset(to + (n - res), 0, res); @@ -387,7 +387,7 @@ static inline unsigned long __must_check copy_to_user(void __user *to, const voi check_object_size(from, n, true); if (access_ok(VERIFY_WRITE, to, n)) { - n = __arch_copy_to_user(to, from, n); + n = __arch_copy_to_user(__uaccess_mask_ptr(to), from, n); } return n; } @@ -395,7 +395,7 @@ static inline unsigned long __must_check copy_to_user(void __user *to, const voi static inline unsigned long __must_check copy_in_user(void __user *to, const void __user *from, unsigned long n) { if (access_ok(VERIFY_READ, from, n) && access_ok(VERIFY_WRITE, to, n)) - n = __copy_in_user(to, from, n); + n = __copy_in_user(__uaccess_mask_ptr(to), __uaccess_mask_ptr(from), n); return n; }