From patchwork Thu Mar 1 12:53:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Shi X-Patchwork-Id: 10251245 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 68BC360365 for ; Thu, 1 Mar 2018 13:01:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CFCA2907C for ; Thu, 1 Mar 2018 13:01:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4873A29112; Thu, 1 Mar 2018 13:01:04 +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 62D3C290DB for ; Thu, 1 Mar 2018 13:00:55 +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:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=QzcvTsbP3taMJv2UE/PFU2xsMG3asZtOd6+oPRQfQjQ=; b=Ia596uO+zMqH1G7nSAJigbkjuK 3hK6VhhhZlY4IpIPNnjNWGgnJOY7ViWuDw8JJMKoA00qwsZiYuZzdnRMKxyij5HT0+oz+w79cUhuj pEUMP7Nqgq2E4wZrsQJZBWZmunIp1qBlfVVHSxkb8uYrXiBor9oN4zluhkiKw6y61PmFz/mXxaAcZ CVa719ju/G7/XKnRC1TAhbjgRSF7dhDBgUw105YZJbjIR+hHIliYLqZ8Rp/VMpET6XPtT9zfaT/zC IlgYY0PM+wK7J2fAY6XZ1pl7tzFwf1zAUTy6I84oh2XjR42xbJYGQRvmOpxW1C0e2qYVRuVOHHQhS PoP76o6w==; 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 1erNpG-0005Cx-Kp; Thu, 01 Mar 2018 13:00:46 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1erNlw-0001Wb-6Y for linux-arm-kernel@lists.infradead.org; Thu, 01 Mar 2018 12:59:00 +0000 Received: by mail-pl0-x244.google.com with SMTP id m22-v6so71031pls.5 for ; Thu, 01 Mar 2018 04:57:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=v4D/ryQu43SY8kOi0wmbmZowM0pzF7fHoEsCU0j3u2A=; b=BqtU3wG2bgy4vwTLvIJC/bT1CEyjcPyP7sFXO2ipd6ozJKn7BQdoeHZauBElg4sgCV 6cMrUeNEuoOMLWIHcQfgeRVaVH+EWTO1Hadw7n3fsn6sXUGZU3wu8rGpqHE2LuuYA4a7 /T9B6WH9ITb7NTrmkLZ5lRHBW34k/jGhZgPUs= 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:in-reply-to :references; bh=v4D/ryQu43SY8kOi0wmbmZowM0pzF7fHoEsCU0j3u2A=; b=c+NdtiiigT7kIjJQiNKiSPtph3k7DKat64aj9yDboX6JsM8/fGVd3mZ2eofdJiVomV MSZikqkTkRU9bEGPVD0f0JIt/axRIZB96ysNQnMvcq0WrtjQO3ezpYcNUthkZsvWURmL dho6DktK1uJyGB50HV0B/uRUsLnelz2qcXsqrAhCJp1KcLjmdEp1EB+/JRctUb6LoJk2 bnXSe9Yejhe8Hwx/AcHYMAx8qN/R9PMyXwKfdrNxw1XFDrz/rGV6D+UhmJAY+uMZfggq Y/y5jl3I/9v8fSQuV/CbcQ3cof21GbF4+lZom1McUc9cN6+EGvMBDtVHdy4+5Ra0wvWx dQiw== X-Gm-Message-State: APf1xPCelEBj6B9Cz/5qkODDmahA4CWo9aT+dy4evk/9k86szySNlsCb SuFLTJlSUQGtH7IkDOh/6alZdg== X-Google-Smtp-Source: AG47ELtM28j3NTErwSRAVBubs8Hmk2rf26vRT1Khl+LQm7c8JZSxQqPOsYTSgkSdDgbgzmYW0mT7mA== X-Received: by 2002:a17:902:9a98:: with SMTP id w24-v6mr1827619plp.188.1519909029401; Thu, 01 Mar 2018 04:57:09 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.57.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:57:08 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/45] arm64: uaccess: Mask __user pointers for __arch_{clear, copy_*}_user Date: Thu, 1 Mar 2018 20:53:52 +0800 Message-Id: <1519908862-11425-16-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180301_045721_170516_205B9AD8 X-CRM114-Status: GOOD ( 13.21 ) 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: , Cc: Alex Shi 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; }