Received: by 10.223.185.116 with SMTP id b49csp7404348wrg; Thu, 1 Mar 2018 05:07:55 -0800 (PST) X-Google-Smtp-Source: AG47ELtmPfypRwl0NUCEbKgdAJf8ZTZ5EY7qEfEr7Ae8rJOI4K/9uKljCZ8Uo8o1HsTTy5IY8feA X-Received: by 2002:a17:902:51e9:: with SMTP id y96-v6mr1908162plh.344.1519909675299; Thu, 01 Mar 2018 05:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909675; cv=none; d=google.com; s=arc-20160816; b=HFlAPPu2AjiTG2LuOcP8KUqdGjyQ2prC+7kEl0DQ3wa/lK3A/4cJ1U/v2tLHkRJExE g0hSchhtKcg2TRK+NoqVdV0g7aqjRzyDzKm1HpVRNY5461lpV8sn6626UL0Hg4ZriJRN rOXH4PJiAHipN6niGx0U085lDGMTf6bt+pNg9LBguQCYcfU5jxuF+5TxUyec3ehCSgOV AHYiDiM35K/xAReIn1gM3s6JnL592sBjQWQJlTtm/6vltUULeSD+EFHIZ3313x7v5LGq V4Duy1p7cPslwBzxWElI5LKNirIm9wq2C8Ve0BQnXXu6960ppbyFjfYidh14oNt3gDBC mVUg== 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:cc:to:from:dkim-signature:arc-authentication-results; bh=v4D/ryQu43SY8kOi0wmbmZowM0pzF7fHoEsCU0j3u2A=; b=kb4cvY4HT+XpptVSUprUzWeJunByk7k/Nh1sKZXZm1VMATBofT9rZKGpLbQKQ/uGaI 4I6bjWy1IasOc798PIsLp7NMhXCK3Y4hJ5QdBZ3GsDxJbKdnENqS3UJ+LCszq4/Hgbv1 4epgzbBXTNJtVlGCdyJWp+7fRLswErriSCslwttQmyEK8ahBfP2kjnUqpj0FwLXjVWFl OudDJnr/qT39kyNPBuLaSR1yojEy2b2rpNVxqPgHKKbFUyfkcUc30ACSlhRSVhz7q8+N FTQwbFSBKSUXLyfN77ZBKMbSHWDCE5q868wcsjGtjZMMM8tUq5bIOEYHRxzDE0TCQuzN u/4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=BqtU3wG2; 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 k13-v6si3168628pln.380.2018.03.01.05.07.40; Thu, 01 Mar 2018 05:07:55 -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=BqtU3wG2; 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 S1030974AbeCANGc (ORCPT + 99 others); Thu, 1 Mar 2018 08:06:32 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:37438 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030800AbeCAM5K (ORCPT ); Thu, 1 Mar 2018 07:57:10 -0500 Received: by mail-pl0-f65.google.com with SMTP id ay8-v6so3589201plb.4 for ; Thu, 01 Mar 2018 04:57:09 -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=R0S6YnWM25iFRJ5YP/bPlfd8kwdg0aL8boh68lcqPWuXkhgBIFJQgSz9iTDUL126Cn XXry5rOlmiq0FV9sexNNWBSmgtbHiExq8vSB3JZe15XYegTTRBX8F8DZ3lE8O/Qchwin ka/qMHm2Qpk8SYg3rEtJ2YVKgtcuqXs40hMLFLETb5qjoxcEjsrtxGh20llPB4SPbXPg Kk7gQH+PoVrB4kCMkioMzxj/SBcTx1Ps3qR+ek69pHb4B8wTQ22fRfQ7wo6EOM81YdQq LYvyjdNsFT8bB5Z8f8A6IE7WOoB9nAtKKEj3nis1qQ6mbsqUEN4QdSU/CqqY7VQ+0tmZ jGoA== X-Gm-Message-State: APf1xPBxLeUYEH6cioawmGAY46pAZuihswhqbcv3ld1jZrN8IcStAmHw GAXEe5dsPpZceytaLPSKMMy21A== 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 Cc: Alex Shi 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> 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(-) 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; } -- 2.7.4