Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2245927pxb; Thu, 11 Feb 2021 07:50:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJy3YUL+OTMhjh4UjoAQwpC/mMNoa8cZaeEKad/DGHuQUfwPIt429xvQEkyygoOd+RW+epVI X-Received: by 2002:a17:907:da3:: with SMTP id go35mr8737042ejc.26.1613058659509; Thu, 11 Feb 2021 07:50:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613058659; cv=none; d=google.com; s=arc-20160816; b=rPrkPQ+dJP5xcJi/2Kj82CEvaMomP6JU0MgHvYQGly6dEv5XAO2e9SNnyluktg58mM UGflXgI0NTfNEABc+PghYfI1FXjBxnGI2YQb71FHcbEYH2xUniP9mjq0V3a2JndbtXgb cZdLYNXjyDqjUSQuyfE1QD/xlLyAlMnJ2coaWJTP0NwaOqOoufSKRBMPM3ITu2Bb4RDt TO903XNWthD6Cfv/g032QYdkVFEZsAfTjbJ6wxpw1W2YJTnIfuQ7+sTT/MFrHMXRqqPM J4U3sFzT1gDclvbPKTuISOJErPMWnC2Dy+nWp0TgYFSRJYtHvIqe5NVxygV6rL9Bpxuv 7+DQ== 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=4jnYlWTtQFlB34Ez/gXD1N1TiaPk4fdjzoA+ugvfYPw=; b=SFrXSD3tPZ9HOFavNdIJ7B9XZ8d/dhr83GExf3uuOLlCIIEueSahxfCKZ7dbEDFiHn T9ZH/t8drtdKC19yiuji52v3hXhv9hbwpH2rBnW1E3E4u2rbu3AlbyTkts/pZdhGrJ/4 VRNYJl9eLg/5Tgo+ycKETBEXTGgZMCaT9n+IOc9AdNn+AagzdKn+6CrBj+lOKFhxH6nN 5MqsC2ucP040I5RDhI6AtZlbSFtW50GNztGgww925L76fWLapE5T2PNKOLwKF4Tj6Mc7 DYkC6mv/8RrP3ytHayYyzBY0XCJHWLSjVKAQWTKpPE7lrB+FhlY97enqcU3wvWcKGnUI EXBA== 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 e16si4047622edy.358.2021.02.11.07.50.35; Thu, 11 Feb 2021 07:50:59 -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 S230107AbhBKPqy (ORCPT + 99 others); Thu, 11 Feb 2021 10:46:54 -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