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=-10.6 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 56FA2C43381 for ; Fri, 5 Feb 2021 23:13:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2890F65008 for ; Fri, 5 Feb 2021 23:13:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232255AbhBEXNB (ORCPT ); Fri, 5 Feb 2021 18:13:01 -0500 Received: from foss.arm.com ([217.140.110.172]:35406 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232507AbhBEO2X (ORCPT ); Fri, 5 Feb 2021 09:28:23 -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 9BA67106F; Fri, 5 Feb 2021 07:41:40 -0800 (PST) Received: from [10.37.8.15] (unknown [10.37.8.15]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4765D3F719; Fri, 5 Feb 2021 07:41:38 -0800 (PST) Subject: Re: [PATCH v11 4/5] arm64: mte: Enable async tag check fault To: Catalin Marinas Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, Andrew Morton , Will Deacon , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Evgenii Stepanov , Branislav Rankov , Andrey Konovalov References: <20210130165225.54047-1-vincenzo.frascino@arm.com> <20210130165225.54047-5-vincenzo.frascino@arm.com> <20210205153918.GA12697@gaia> From: Vincenzo Frascino Message-ID: <1254c150-599c-d39d-3b83-8af4f3c403ee@arm.com> Date: Fri, 5 Feb 2021 15:45:38 +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: <20210205153918.GA12697@gaia> 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 2/5/21 3:39 PM, Catalin Marinas wrote: > On Sat, Jan 30, 2021 at 04:52:24PM +0000, Vincenzo Frascino wrote: >> diff --git a/arch/arm64/kernel/mte.c b/arch/arm64/kernel/mte.c >> index 92078e1eb627..7763ac1f2917 100644 >> --- a/arch/arm64/kernel/mte.c >> +++ b/arch/arm64/kernel/mte.c >> @@ -182,6 +182,37 @@ bool mte_report_once(void) >> return READ_ONCE(report_fault_once); >> } >> >> +#ifdef CONFIG_KASAN_HW_TAGS >> +void mte_check_tfsr_el1(void) >> +{ >> + u64 tfsr_el1; >> + >> + if (!system_supports_mte()) >> + return; >> + >> + tfsr_el1 = read_sysreg_s(SYS_TFSR_EL1); >> + >> + /* >> + * The kernel should never trigger an asynchronous fault on a >> + * TTBR0 address, so we should never see TF0 set. >> + * For futexes we disable checks via PSTATE.TCO. >> + */ >> + WARN_ONCE(tfsr_el1 & SYS_TFSR_EL1_TF0, >> + "Kernel async tag fault on TTBR0 address"); > > Sorry, I got confused when I suggested this warning. If the user is > running in async mode, the TFSR_EL1.TF0 bit may be set by > copy_mount_options(), strncpy_from_user() which rely on an actual fault > happening (not the case with asynchronous where only a bit is set). With > the user MTE support, we never report asynchronous faults caused by the > kernel on user addresses as we can't easily track them. So this warning > may be triggered on correctly functioning kernel/user. > No issue, I will re-post removing the WARN_ONCE(). >> + >> + if (unlikely(tfsr_el1 & SYS_TFSR_EL1_TF1)) { >> + /* >> + * Note: isb() is not required after this direct write >> + * because there is no indirect read subsequent to it >> + * (per ARM DDI 0487F.c table D13-1). >> + */ >> + write_sysreg_s(0, SYS_TFSR_EL1); > > Zeroing the whole register is still fine, we don't care about the TF0 > bit anyway. > >> + >> + kasan_report_async(); >> + } >> +} >> +#endif > -- Regards, Vincenzo