From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi0-f70.google.com (mail-oi0-f70.google.com [209.85.218.70]) by kanga.kvack.org (Postfix) with ESMTP id BAD6C6B0007 for ; Thu, 26 Apr 2018 11:47:34 -0400 (EDT) Received: by mail-oi0-f70.google.com with SMTP id d1-v6so819186oib.23 for ; Thu, 26 Apr 2018 08:47:34 -0700 (PDT) Received: from foss.arm.com (foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id w2-v6si7057919oig.232.2018.04.26.08.47.33 for ; Thu, 26 Apr 2018 08:47:33 -0700 (PDT) Date: Thu, 26 Apr 2018 16:47:25 +0100 From: Catalin Marinas Subject: Re: [PATCH 3/6] arm64: untag user addresses in copy_from_user and others Message-ID: <20180426154725.74a33tnevvbtqx63@armageddon.cambridge.arm.com> References: <949c343a4b02b41b80f324c2b7cd56b75e6a04f3.1524077494.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <949c343a4b02b41b80f324c2b7cd56b75e6a04f3.1524077494.git.andreyknvl@google.com> Sender: owner-linux-mm@kvack.org List-ID: To: Andrey Konovalov Cc: Will Deacon , Jonathan Corbet , Mark Rutland , Robin Murphy , Al Viro , James Morse , Kees Cook , Bart Van Assche , Kate Stewart , Greg Kroah-Hartman , Thomas Gleixner , Philippe Ombredanne , Andrew Morton , Ingo Molnar , "Kirill A . Shutemov" , Dan Williams , "Aneesh Kumar K . V" , Zi Yan , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Jacob Bramley , Ruben Ayrapetyan , Lee Smith , Kostya Serebryany , Dmitry Vyukov , Ramana Radhakrishnan , Evgeniy Stepanov On Wed, Apr 18, 2018 at 08:53:12PM +0200, Andrey Konovalov wrote: > @@ -238,12 +239,15 @@ static inline void uaccess_enable_not_uao(void) > /* > * Sanitise a uaccess pointer such that it becomes NULL if above the > * current addr_limit. > + * Also untag user pointers that have the top byte tag set. > */ > #define uaccess_mask_ptr(ptr) (__typeof__(ptr))__uaccess_mask_ptr(ptr) > static inline void __user *__uaccess_mask_ptr(const void __user *ptr) > { > void __user *safe_ptr; > > + ptr = untagged_addr(ptr); > + > asm volatile( > " bics xzr, %1, %2\n" > " csel %0, %1, xzr, eq\n" First of all, passing a tagged user pointer throughout the kernel is safe with uaccess routines but not suitable for find_vma() etc. With this change, we may have an inconsistent behaviour on the tag masking, depending on whether the entry code uses __uaccess_mask_ptr() or not. We could preserve the tag with something like: diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index e66b0fca99c2..ed15bfcbd797 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -244,10 +244,11 @@ static inline void __user *__uaccess_mask_ptr(const void __user *ptr) void __user *safe_ptr; asm volatile( - " bics xzr, %1, %2\n" + " bics xzr, %3, %2\n" " csel %0, %1, xzr, eq\n" : "=&r" (safe_ptr) - : "r" (ptr), "r" (current_thread_info()->addr_limit) + : "r" (ptr), "r" (current_thread_info()->addr_limit), + "r" (untagged_addr(ptr)) : "cc"); csdb(); -- Catalin