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.4 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 4A496C433DB for ; Thu, 11 Feb 2021 15:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1B0BF601FB for ; Thu, 11 Feb 2021 15:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231229AbhBKPrJ (ORCPT ); Thu, 11 Feb 2021 10:47:09 -0500 Received: from foss.arm.com ([217.140.110.172]:53282 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbhBKPRm (ORCPT ); Thu, 11 Feb 2021 10:17:42 -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 0EC95113E; Thu, 11 Feb 2021 07:06:23 -0800 (PST) Received: from [10.37.8.13] (unknown [10.37.8.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D20EA3F73D; Thu, 11 Feb 2021 07:06:21 -0800 (PST) Subject: Re: [PATCH] arm64: Fix warning in mte_get_random_tag() To: Ard Biesheuvel Cc: Linux ARM , Linux Kernel Mailing List , kasan-dev , Catalin Marinas , Andrew Morton , Will Deacon , Andrey Konovalov References: <20210211125602.44248-1-vincenzo.frascino@arm.com> From: Vincenzo Frascino Message-ID: <49a080e6-4482-0d8a-2360-eba698b92457@arm.com> Date: Thu, 11 Feb 2021 15:10:27 +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: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/11/21 1:35 PM, Ard Biesheuvel wrote: > On Thu, 11 Feb 2021 at 13:57, Vincenzo Frascino > wrote: >> >> The simplification of mte_get_random_tag() caused the introduction of the >> warning below: >> >> In file included from arch/arm64/include/asm/kasan.h:9, >> from include/linux/kasan.h:16, >> from mm/kasan/common.c:14: >> mm/kasan/common.c: In function ‘mte_get_random_tag’: >> arch/arm64/include/asm/mte-kasan.h:45:9: warning: ‘addr’ is used >> uninitialized [-Wuninitialized] >> 45 | asm(__MTE_PREAMBLE "irg %0, %0" >> | >> >> Fix the warning initializing the address to NULL. >> >> Note: mte_get_random_tag() returns a tag and it never dereferences the address, >> hence 'addr' can be safely initialized to NULL. >> >> Fixes: c8f8de4c0887 ("arm64: kasan: simplify and inline MTE functions") >> Cc: Catalin Marinas >> Cc: Will Deacon >> Cc: Andrey Konovalov >> Cc: Andrew Morton >> Signed-off-by: Vincenzo Frascino >> --- >> >> This patch is based on linux-next/akpm >> >> arch/arm64/include/asm/mte-kasan.h | 7 ++++++- >> 1 file changed, 6 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm64/include/asm/mte-kasan.h b/arch/arm64/include/asm/mte-kasan.h >> index 3d58489228c0..b2850b750726 100644 >> --- a/arch/arm64/include/asm/mte-kasan.h >> +++ b/arch/arm64/include/asm/mte-kasan.h >> @@ -40,7 +40,12 @@ static inline u8 mte_get_mem_tag(void *addr) >> /* Generate a random tag. */ >> static inline u8 mte_get_random_tag(void) >> { >> - void *addr; >> + /* >> + * mte_get_random_tag() returns a tag and it >> + * never dereferences the address, hence addr >> + * can be safely initialized to NULL. >> + */ >> + void *addr = NULL; >> >> asm(__MTE_PREAMBLE "irg %0, %0" >> : "+r" (addr)); >> -- >> 2.30.0 >> > > Might it be better to simply change the asm constraint to "=r" ? > Indeed, did not notice the "+r". I will change it accordingly and post v2. Thanks! -- Regards, Vincenzo