All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: Fix warning in mte_get_random_tag()
@ 2021-02-11 12:56 ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2021-02-11 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, kasan-dev
  Cc: Vincenzo Frascino, Catalin Marinas, Will Deacon,
	Andrey Konovalov, Andrew Morton

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 <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] arm64: Fix warning in mte_get_random_tag()
@ 2021-02-11 12:56 ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2021-02-11 12:56 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, kasan-dev
  Cc: Catalin Marinas, Andrew Morton, Vincenzo Frascino, Will Deacon,
	Andrey Konovalov

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 <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Andrey Konovalov <andreyknvl@google.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
---

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: Fix warning in mte_get_random_tag()
  2021-02-11 12:56 ` Vincenzo Frascino
@ 2021-02-11 13:35   ` Ard Biesheuvel
  -1 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2021-02-11 13:35 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Linux ARM, Linux Kernel Mailing List, kasan-dev, Catalin Marinas,
	Andrew Morton, Will Deacon, Andrey Konovalov

On Thu, 11 Feb 2021 at 13:57, Vincenzo Frascino
<vincenzo.frascino@arm.com> 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 <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Andrey Konovalov <andreyknvl@google.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>
> 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" ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: Fix warning in mte_get_random_tag()
@ 2021-02-11 13:35   ` Ard Biesheuvel
  0 siblings, 0 replies; 6+ messages in thread
From: Ard Biesheuvel @ 2021-02-11 13:35 UTC (permalink / raw)
  To: Vincenzo Frascino
  Cc: Catalin Marinas, Linux Kernel Mailing List, kasan-dev,
	Andrey Konovalov, Andrew Morton, Will Deacon, Linux ARM

On Thu, 11 Feb 2021 at 13:57, Vincenzo Frascino
<vincenzo.frascino@arm.com> 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 <catalin.marinas@arm.com>
> Cc: Will Deacon <will@kernel.org>
> Cc: Andrey Konovalov <andreyknvl@google.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
> ---
>
> 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" ?

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: Fix warning in mte_get_random_tag()
  2021-02-11 13:35   ` Ard Biesheuvel
@ 2021-02-11 15:10     ` Vincenzo Frascino
  -1 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2021-02-11 15:10 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Linux ARM, Linux Kernel Mailing List, kasan-dev, Catalin Marinas,
	Andrew Morton, Will Deacon, Andrey Konovalov



On 2/11/21 1:35 PM, Ard Biesheuvel wrote:
> On Thu, 11 Feb 2021 at 13:57, Vincenzo Frascino
> <vincenzo.frascino@arm.com> 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 <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Andrey Konovalov <andreyknvl@google.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>
>> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] arm64: Fix warning in mte_get_random_tag()
@ 2021-02-11 15:10     ` Vincenzo Frascino
  0 siblings, 0 replies; 6+ messages in thread
From: Vincenzo Frascino @ 2021-02-11 15:10 UTC (permalink / raw)
  To: Ard Biesheuvel
  Cc: Catalin Marinas, Linux Kernel Mailing List, kasan-dev,
	Andrey Konovalov, Andrew Morton, Will Deacon, Linux ARM



On 2/11/21 1:35 PM, Ard Biesheuvel wrote:
> On Thu, 11 Feb 2021 at 13:57, Vincenzo Frascino
> <vincenzo.frascino@arm.com> 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 <catalin.marinas@arm.com>
>> Cc: Will Deacon <will@kernel.org>
>> Cc: Andrey Konovalov <andreyknvl@google.com>
>> Cc: Andrew Morton <akpm@linux-foundation.org>
>> Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
>> ---
>>
>> 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

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-11 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-11 12:56 [PATCH] arm64: Fix warning in mte_get_random_tag() Vincenzo Frascino
2021-02-11 12:56 ` Vincenzo Frascino
2021-02-11 13:35 ` Ard Biesheuvel
2021-02-11 13:35   ` Ard Biesheuvel
2021-02-11 15:10   ` Vincenzo Frascino
2021-02-11 15:10     ` Vincenzo Frascino

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.