Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp170848pxb; Fri, 15 Jan 2021 10:02:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEjFRURnxAIy6JKJkrCx6feN8xAupJKwDfKbvBfrGuD2H9yIKX0MyF+hwEa2x5is5NcaC7 X-Received: by 2002:a17:906:d152:: with SMTP id br18mr9754846ejb.297.1610733752373; Fri, 15 Jan 2021 10:02:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610733752; cv=none; d=google.com; s=arc-20160816; b=nbmOKCngwBBcV51O9pCcJ1zGFQ7+P4PoEklVcaUa1j1M+x0hagOZNBYQdbh5S4P7eG rxDEL1Uj3zwSEMZO1FMs6zxX/QoNY+DJK+Ttahvs+eqstP8BM6X6Nk4H4Yu0ZkFqP5oh uUA3Jl8o0ho+lMWlvlWELTEZBp0ia/6vIpxVVND8n1xT8NisYqa21vlilgllcrGnwvPH w7TbNSmIMq4VS7jgvZan5pylCHewyQpxmEFNhZ6a4r2FtX251yqLLDSBEQK/GyqLbb+V Vz8ZrQz0BF+EiI0ZGRcGeg1klKGj2j2BiGr7LmlXotn5J2OHWaBm+gEfmvIO8tLexbvU Rp9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=xTiOIlAimJwFNRzca0FQkYkDDXZoA7RFp+lSIj5BFJ8=; b=xKA0qkDI+Fxev+q1JzSZBHt+Fa1qYxmS30k+IMIKJ9PgFP33gV2X/oNMAYj7AqXmOD zUkBdF9QQSEdOBXKt+TVSZtrSdmrUgdvzysl+657/0HSo1kSd1h9lOQvXrP6xb+0urfR j2mi+GVm01UAIndvorZKJJ9nrAN3vOaAozK9LWPJwsRaZuqebgUuajt3C6GBnwSF6bLG AJvc48JrXW7bUpVBU7umnqgSin27edweQnUWd6pZCcTZkw+A7H2flrwn+Z4dGGgQTkWp qy+wAnG4lBjrWBjcipJlFsDWFNtYgMkQKG8foV8izO0YMeM9rwbQG/yqy/CxAJXPJndF PYEg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u25si4473088edv.571.2021.01.15.10.02.08; Fri, 15 Jan 2021 10:02:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbhAOSAw (ORCPT + 99 others); Fri, 15 Jan 2021 13:00:52 -0500 Received: from foss.arm.com ([217.140.110.172]:48824 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728310AbhAOSAw (ORCPT ); Fri, 15 Jan 2021 13:00:52 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B0CC1ED1; Fri, 15 Jan 2021 10:00:06 -0800 (PST) Received: from [10.37.8.30] (unknown [10.37.8.30]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F33C03F719; Fri, 15 Jan 2021 10:00:02 -0800 (PST) Subject: Re: [PATCH v3 2/2] kasan, arm64: fix pointer tags in KASAN reports To: Andrey Konovalov , Andrew Morton , Catalin Marinas , Dmitry Vyukov , Alexander Potapenko , Marco Elver Cc: Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev@googlegroups.com, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org References: From: Vincenzo Frascino Message-ID: <2dfd9776-4b8f-45f8-b673-ecb7fa6e16be@arm.com> Date: Fri, 15 Jan 2021 18:03:49 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/15/21 5:41 PM, Andrey Konovalov wrote: > As of the "arm64: expose FAR_EL1 tag bits in siginfo" patch, the address > that is passed to report_tag_fault has pointer tags in the format of 0x0X, > while KASAN uses 0xFX format (note the difference in the top 4 bits). > > Fix up the pointer tag for kernel pointers in do_tag_check_fault by > setting them to the same value as bit 55. Explicitly use __untagged_addr() > instead of untagged_addr(), as the latter doesn't affect TTBR1 addresses. > > Link: https://linux-review.googlesource.com/id/I9ced973866036d8679e8f4ae325de547eb969649 > Fixes: dceec3ff7807 ("arm64: expose FAR_EL1 tag bits in siginfo") > Fixes: 4291e9ee6189 ("kasan, arm64: print report from tag fault handler") > Signed-off-by: Andrey Konovalov Reviewed-by: Vincenzo Frascino > --- > arch/arm64/mm/fault.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c > index 3c40da479899..35d75c60e2b8 100644 > --- a/arch/arm64/mm/fault.c > +++ b/arch/arm64/mm/fault.c > @@ -709,10 +709,11 @@ static int do_tag_check_fault(unsigned long far, unsigned int esr, > struct pt_regs *regs) > { > /* > - * The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN for tag > - * check faults. Mask them out now so that userspace doesn't see them. > + * The architecture specifies that bits 63:60 of FAR_EL1 are UNKNOWN > + * for tag check faults. Set them to corresponding bits in the untagged > + * address. > */ > - far &= (1UL << 60) - 1; > + far = (__untagged_addr(far) & ~MTE_TAG_MASK) | (far & MTE_TAG_MASK); > do_bad_area(far, esr, regs); > return 0; > } > -- Regards, Vincenzo