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: 129612 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3366221lja; Mon, 26 Feb 2018 00:36:46 -0800 (PST) X-Google-Smtp-Source: AH8x2242SPIjaLsJ2dQB4A9Woovd10/D19L9Sfknra0AuwhPweQClnoywpnbDaMod3KzEGs+d0Mq X-Received: by 10.101.87.132 with SMTP id b4mr7698291pgr.282.1519634206587; Mon, 26 Feb 2018 00:36:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519634206; cv=none; d=google.com; s=arc-20160816; b=CFmZDz56zHd+aeJSTi4LKNDx7gPRAcr0A4iO5bJlle9jPsJtU5cy5zqwJf9WPiMffp 8C9xdTmfoMkP4ELkzG+Wv2fSSBXjbiBeX2Q0Lhre18AXgxn1QETne6ONp4vNPDEEO0RI 408/WSg2ObRAsZKVMaM1YcbGqOjIjB2Dksq6wuT8VoYZ+gmLczJ8X6ta0pN6Zri0AXD+ +QRwcSCan6uN+vgbuiNKvisDDw8YSPABN1TRJpXjPb8Oo5dnHuhhBac+Ime5AJVRXbln NizPPlHLqx/OaIrnwH6J84nGWZ85qyWlEcUCNReV1J1zkThP19PKyag8Nv4OWKOWrq+i UTHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:arc-authentication-results; bh=iAPTv5jlMzw6ovOzicmoLxGXCxHRzs8GBzIryr4d66U=; b=V8rSjfDirA6JqxPs6Rj0tSd1Fmd7DDG2fZS4XtfVfMc+Vq9S2cZdPXNPgofqszneNT Z26PN5njMhMtlK4wVXSby2W8I6stkhO1FA5MINbkACjxcGo2rpSHhioOcGnfsepKRQZt ozKjdzUlb6gJw+T6Tg4mrbGk8ZqF0LS4ndPjvBGYlk5R6pt8re3/G0MXd6FD7aiSvgDo alzoQeU+5I1SZ4Yu0sFOfF61FRiXeo331HmSU8g3joqGGluG9Pk+30kl9OeffIo4hRBX ZWLivQEwpbf5tSrC8wZ8hx7EgGroTyt3lSxmha2P1zMauyyDqK91ZQlnEq82Z/NnrywJ XSRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YBfQoz1u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g9si5238858pgs.752.2018.02.26.00.36.46; Mon, 26 Feb 2018 00:36:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YBfQoz1u; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752500AbeBZIgl (ORCPT + 28 others); Mon, 26 Feb 2018 03:36:41 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:46556 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752037AbeBZIW5 (ORCPT ); Mon, 26 Feb 2018 03:22:57 -0500 Received: by mail-pg0-f66.google.com with SMTP id r26so676279pgv.13 for ; Mon, 26 Feb 2018 00:22:57 -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=lt7eraSC3/an94+nky1b6mlNvkpOEVE7aIAaBBm6ZvgkgkAXjxza2IjHuy5VJm4s2u gUvWKomoCKPiCo0FDfGzT6OdfwXKTPIpbjCP/sfNaELyLf60tIAADcnkatH0d9HEadi0 XK+SU87GNVXaTHAOgVYr9tYIPez9zKaj75196WU5wgJR8azGQIKnRKPNaAjKGJi6C5sx kW+w7ydOgXxpc1wKJbKDHvvW68BZHYWTFdGgcmjn0KIG7FeU1FvJcr6Zi2Thp36QfsyR 7CKXNhHh4sWR4uMsJcUuYFgvh2F6DzqsOkYsDrHxs2H7Au/Gpi4OFbjIOrjEPm3kTljY MxIA== X-Gm-Message-State: APf1xPB2GUhfxCCfUjbYEs0675gfFhcpUWGCjDEH1z9qZfZ2I7tjJC1g DggZ0sl5YlQ9bMW5ElbtSxSMbg== 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 2.7.4 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; }