From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_NEOMUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B574C43441 for ; Fri, 23 Nov 2018 17:37:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3FFCA20865 for ; Fri, 23 Nov 2018 17:37:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3FFCA20865 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2440933AbeKXEXA (ORCPT ); Fri, 23 Nov 2018 23:23:00 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:49888 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437062AbeKXEXA (ORCPT ); Fri, 23 Nov 2018 23:23:00 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BF7273574; Fri, 23 Nov 2018 09:37:47 -0800 (PST) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E3FF23F5CF; Fri, 23 Nov 2018 09:37:41 -0800 (PST) Date: Fri, 23 Nov 2018 17:37:39 +0000 From: Mark Rutland To: Andrey Konovalov Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Catalin Marinas , Will Deacon , Christoph Lameter , Andrew Morton , Nick Desaulniers , Marc Zyngier , Dave Martin , Ard Biesheuvel , "Eric W . Biederman" , Ingo Molnar , Paul Lawrence , Geert Uytterhoeven , Arnd Bergmann , "Kirill A . Shutemov" , Greg Kroah-Hartman , Kate Stewart , Mike Rapoport , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sparse@vger.kernel.org, linux-mm@kvack.org, linux-kbuild@vger.kernel.org, Kostya Serebryany , Evgeniy Stepanov , Lee Smith , Ramana Radhakrishnan , Jacob Bramley , Ruben Ayrapetyan , Jann Horn , Mark Brand , Chintan Pandya , Vishwath Mohan Subject: Re: [PATCH v11 09/24] arm64: move untagged_addr macro from uaccess.h to memory.h Message-ID: <20181123173739.osgvnnhmptdgtlnl@lakrids.cambridge.arm.com> References: <0288334225edc99d98d70c896494e19c3bd9361a.1542648335.git.andreyknvl@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0288334225edc99d98d70c896494e19c3bd9361a.1542648335.git.andreyknvl@google.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 19, 2018 at 06:26:25PM +0100, Andrey Konovalov wrote: > Move the untagged_addr() macro from arch/arm64/include/asm/uaccess.h > to arch/arm64/include/asm/memory.h to be later reused by KASAN. > > Also make the untagged_addr() macro accept all kinds of address types > (void *, unsigned long, etc.). This allows not to specify type casts in > each place where the macro is used. This is done by using __typeof__. > > Signed-off-by: Andrey Konovalov > --- > arch/arm64/include/asm/memory.h | 8 ++++++++ > arch/arm64/include/asm/uaccess.h | 7 ------- > 2 files changed, 8 insertions(+), 7 deletions(-) > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > index 05fbc7ffcd31..deb95be44392 100644 > --- a/arch/arm64/include/asm/memory.h > +++ b/arch/arm64/include/asm/memory.h > @@ -73,6 +73,14 @@ > #define KERNEL_START _text > #define KERNEL_END _end > > +/* > + * When dealing with data aborts, watchpoints, or instruction traps we may end > + * up with a tagged userland pointer. Clear the tag to get a sane pointer to > + * pass on to access_ok(), for instance. > + */ > +#define untagged_addr(addr) \ > + (__typeof__(addr))sign_extend64((__u64)(addr), 55) Minor nits: * s/__u64/u64/ (or s/__u64/unsigned long/), since this isn't a UAPI header. * Please move this down into the #ifndef __ASSEMBLY__ block, after we include , which is necessary for sign_extend64(). With those fixed up, this patch looks sound to me: Acked-by: Mark Rutland Thanks, Mark. > + > /* > * Generic and tag-based KASAN require 1/8th and 1/16th of the kernel virtual > * address space for the shadow region respectively. They can bloat the stack > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index 07c34087bd5e..281a1e47263d 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -96,13 +96,6 @@ static inline unsigned long __range_ok(const void __user *addr, unsigned long si > return ret; > } > > -/* > - * When dealing with data aborts, watchpoints, or instruction traps we may end > - * up with a tagged userland pointer. Clear the tag to get a sane pointer to > - * pass on to access_ok(), for instance. > - */ > -#define untagged_addr(addr) sign_extend64(addr, 55) > - > #define access_ok(type, addr, size) __range_ok(addr, size) > #define user_addr_max get_fs > > -- > 2.19.1.1215.g8438c0b245-goog >