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=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 A3556C433EF for ; Tue, 21 Sep 2021 13:25:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6F47F61090 for ; Tue, 21 Sep 2021 13:25:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6F47F61090 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=fUUOVkrG+3kJ5qdXkURWFTACUTEqIn9Aik2eENqlysw=; b=IXR8JMY5VzVSRx 9UOjdBC1l1dGsZ3Q9NG6i0oJuw/aYHPE0QX9SGjVIO6n9wvT9zhOAi0F6XJDKZTrRyx7tgWJ9Wc0y /b7YL4owbwlZ/Fd+FZBlMqHQzf/zdDpZXMWPgTCV/PRJRhgOFJEz2LxLp4At4QsW2WmxS201nzOl8 oCExWL5aAvo32VjW5OYyFDVbtLsl8wBnquKhE9VdDMnGNy/UQ5Jm36xIxlLj8hp62VfFBOR+6vMwS d/dJta+diJ/oCWFkvkXf6XyjP2QEj6Matvf6AjdnIcLEyXksNyobVKtq+47pNGx5f9l9oWWD1arVm lmWT9m2Q88TexPbZHRdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSfk0-004Ykv-Nn; Tue, 21 Sep 2021 13:23:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mSfjw-004YkF-QK for linux-arm-kernel@lists.infradead.org; Tue, 21 Sep 2021 13:23:18 +0000 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 F16DD106F; Tue, 21 Sep 2021 06:23:09 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.23.155]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B4C5F3F59C; Tue, 21 Sep 2021 06:23:08 -0700 (PDT) Date: Tue, 21 Sep 2021 14:23:01 +0100 From: Mark Rutland To: Robin Murphy Cc: will@kernel.org, catalin.marinas@arm.com, linux-arm-kernel@lists.infradead.org, Branislav Rankov Subject: Re: [PATCH] arm64: Mitigate MTE issues with str{n}cmp() Message-ID: <20210921132301.GA35846@C02TD0UTHF1T.local> References: <34dc4d12eec0adae49b0ac927df642ed10089d40.1631890770.git.robin.murphy@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <34dc4d12eec0adae49b0ac927df642ed10089d40.1631890770.git.robin.murphy@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210921_062317_024606_841A8F87 X-CRM114-Status: GOOD ( 21.22 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Sep 17, 2021 at 03:59:30PM +0100, Robin Murphy wrote: > As with strlen(), the patches importing the updated str{n}cmp() > implementations were originally developed and tested before the > advent of CONFIG_KASAN_HW_TAGS, and have subsequently revealed > not to be MTE-safe. Since in-kernel MTE is still a rather niche > case, let it temporarily fall back to the generic C versions for > correctness until we can figure out the best fix. > > Reported-by: Branislav Rankov > Signed-off-by: Robin Murphy > --- > arch/arm64/include/asm/assembler.h | 5 +++++ > arch/arm64/include/asm/string.h | 2 ++ > arch/arm64/lib/strcmp.S | 2 +- > arch/arm64/lib/strncmp.S | 2 +- > 4 files changed, 9 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h > index 89faca0e740d..bfa58409a4d4 100644 > --- a/arch/arm64/include/asm/assembler.h > +++ b/arch/arm64/include/asm/assembler.h > @@ -525,6 +525,11 @@ alternative_endif > #define EXPORT_SYMBOL_NOKASAN(name) EXPORT_SYMBOL(name) > #endif > > +#ifdef CONFIG_KASAN_HW_TAGS > +#define EXPORT_SYMBOL_NOHWKASAN(name) > +#else > +#define EXPORT_SYMBOL_NOHWKASAN(name) EXPORT_SYMBOL_NOKASAN(name) > +#endif I think that depending on how we solve this in future, we might want to have: * EXPORT_SYMBOL_NOSWKASAN for generic/sw-tags (this would be a rename of the existing EXPORT_SYMBOL_NOKASAN) * EXPORT_SYMBOL_NOHWKASAN for hw tags * EXPORT_SYMBOL_NOKASAN for generic/sw-tags/hw-tags ... so then it's a bit clearer what's handled in each case. Regardless, for now this is certainly good enough. FWIW: Acked-by: Mark Rutland Thanks, Mark. > /* > * Emit a 64-bit absolute little endian symbol reference in a way that > * ensures that it will be resolved at build time, even when building a > diff --git a/arch/arm64/include/asm/string.h b/arch/arm64/include/asm/string.h > index 3a3264ff47b9..95f7686b728d 100644 > --- a/arch/arm64/include/asm/string.h > +++ b/arch/arm64/include/asm/string.h > @@ -12,11 +12,13 @@ extern char *strrchr(const char *, int c); > #define __HAVE_ARCH_STRCHR > extern char *strchr(const char *, int c); > > +#ifndef CONFIG_KASAN_HW_TAGS > #define __HAVE_ARCH_STRCMP > extern int strcmp(const char *, const char *); > > #define __HAVE_ARCH_STRNCMP > extern int strncmp(const char *, const char *, __kernel_size_t); > +#endif > > #define __HAVE_ARCH_STRLEN > extern __kernel_size_t strlen(const char *); > diff --git a/arch/arm64/lib/strcmp.S b/arch/arm64/lib/strcmp.S > index d7bee210a798..83bcad72ec97 100644 > --- a/arch/arm64/lib/strcmp.S > +++ b/arch/arm64/lib/strcmp.S > @@ -173,4 +173,4 @@ L(done): > ret > > SYM_FUNC_END_PI(strcmp) > -EXPORT_SYMBOL_NOKASAN(strcmp) > +EXPORT_SYMBOL_NOHWKASAN(strcmp) > diff --git a/arch/arm64/lib/strncmp.S b/arch/arm64/lib/strncmp.S > index 48d44f7fddb1..e42bcfcd37e6 100644 > --- a/arch/arm64/lib/strncmp.S > +++ b/arch/arm64/lib/strncmp.S > @@ -258,4 +258,4 @@ L(ret0): > ret > > SYM_FUNC_END_PI(strncmp) > -EXPORT_SYMBOL_NOKASAN(strncmp) > +EXPORT_SYMBOL_NOHWKASAN(strncmp) > -- > 2.21.0.dirty > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel