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.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 61616C07E99 for ; Mon, 12 Jul 2021 11:20:24 +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 24FC560FF1 for ; Mon, 12 Jul 2021 11:20:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 24FC560FF1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@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=ofDj9ytMaXSD6tVYkUcVDrTRjE3pV6ZbEKOh2b2ndD4=; b=MqWtFVK0isTb77 Acu+6GgmkB8HBKgzH28h7ci8V3OXnEIBhaLL2Pl/YqY9yjcKyzOInNVu6QPCebYLngIcdjS9fakO5 5XhBLtfr2An2D6BTQ1jtXNSbax68wknUvmSoBMcBdmCjrMW+2lvApSnNLd2iRhbyaUon8oP3ihPFd MlrECRz081DLc6zqt/fSjpAarXcB5LGsWX9/PfYTFmllZAUVM4aq6gWg9p3Pom757swvjl/l34knY CmqFPaa9oZKKOAdS3aFLM5vVp7seuONjMYIEBW22wG8pz/poL7jYRuELoC98U6hF8InXxHXmjcJzV F0WpDXJFTtk+5TywC8pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2txy-0077R2-7b; Mon, 12 Jul 2021 11:19:14 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m2txv-0077Q8-2h for linux-arm-kernel@lists.infradead.org; Mon, 12 Jul 2021 11:19:12 +0000 Received: by mail.kernel.org (Postfix) with ESMTPSA id E522D61003; Mon, 12 Jul 2021 11:19:08 +0000 (UTC) Date: Mon, 12 Jul 2021 12:19:06 +0100 From: Catalin Marinas To: Marco Elver Cc: Mark Rutland , will@kernel.org, linux-arm-kernel@lists.infradead.org, Alexander Potapenko , Andrey Konovalov , Andrey Ryabinin , Dmitry Vyukov , Robin Murphy Subject: Re: [PATCH] arm64: fix strlen() with CONFIG_KASAN_HW_TAGS Message-ID: <20210712111905.GA1992@arm.com> References: <20210712090043.20847-1-mark.rutland@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210712_041911_193001_F6FC0750 X-CRM114-Status: GOOD ( 20.37 ) 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 Mon, Jul 12, 2021 at 11:24:14AM +0200, Marco Elver wrote: > On Mon, 12 Jul 2021 at 11:00, Mark Rutland wrote: > > diff --git a/arch/arm64/lib/strlen.S b/arch/arm64/lib/strlen.S > > index 35fbdb7d6e1a..1648790e91b3 100644 > > --- a/arch/arm64/lib/strlen.S > > +++ b/arch/arm64/lib/strlen.S > > @@ -8,6 +8,7 @@ > > > > #include > > #include > > +#include > > > > /* Assumptions: > > * > > @@ -42,7 +43,16 @@ > > #define REP8_7f 0x7f7f7f7f7f7f7f7f > > #define REP8_80 0x8080808080808080 > > > > +/* > > + * When KASAN_HW_TAGS is in use, memory is checked at MTE_GRANULE_SIZE > > + * (16-byte) granularity, and we must ensure that no access straddles this > > + * alignment boundary. > > + */ > > +#ifdef CONFIG_KASAN_HW_TAGS > > +#define MIN_PAGE_SIZE MTE_GRANULE_SIZE > > +#else > > #define MIN_PAGE_SIZE 4096 > > +#endif > > > > /* Since strings are short on average, we check the first 16 bytes > > of the string for a NUL character. In order to do an unaligned ldp > > Glancing at the code below this hunk, I see some hard coded 16, > presumably referencing the comment here. Is the algorithm tolerant to > MIN_PAGE_SIZE<16? I suppose that's only an issue if the granule size > might become less than 16 for some config in future. It's probably not tolerant as we have a cmp with MIN_PAGE_SIZE - 16. But I'm not worried, the architecture won't go below this without some explicit opt-in. Anyway, we can add an #error MTE_GRANULE_SIZE < 16, just in case anyone plays with this macro. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel