LKML Archive on
help / color / mirror / Atom feed
From: Nathan Chancellor <>
To: Andrey Ryabinin <>,
	Alexander Potapenko <>,
	Dmitry Vyukov <>
	Nick Desaulniers <>,,
	Nathan Chancellor <>
Subject: [PATCH] kasan: Zero initialize tag in __kasan_kmalloc
Date: Thu,  2 May 2019 08:35:38 -0700	[thread overview]
Message-ID: <> (raw)

When building with -Wuninitialized and CONFIG_KASAN_SW_TAGS unset, Clang

mm/kasan/common.c:484:40: warning: variable 'tag' is uninitialized when
used here [-Wuninitialized]
        kasan_unpoison_shadow(set_tag(object, tag), size);

set_tag ignores tag in this configuration but clang doesn't realize it
at this point in its pipeline, as it points to arch_kasan_set_tag as
being the point where it is used, which will later be expanded to
(void *)(object) without a use of tag. Just zero initialize tag, as it
removes this warning and doesn't change the meaning of the code.

Signed-off-by: Nathan Chancellor <>
 mm/kasan/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/kasan/common.c b/mm/kasan/common.c
index 36afcf64e016..4c5af68f2a8b 100644
--- a/mm/kasan/common.c
+++ b/mm/kasan/common.c
@@ -464,7 +464,7 @@ static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object,
 	unsigned long redzone_start;
 	unsigned long redzone_end;
-	u8 tag;
+	u8 tag = 0;
 	if (gfpflags_allow_blocking(flags))

             reply	other threads:[~2019-05-02 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-02 15:35 Nathan Chancellor [this message]
2019-05-02 16:24 ` Andrey Konovalov
2019-05-02 16:30 ` [PATCH v2] kasan: Initialize tag to 0xff " Nathan Chancellor
2019-05-02 16:40   ` Andrey Konovalov
2019-05-23  1:47     ` Nathan Chancellor
2019-05-23  8:53   ` Andrey Ryabinin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] kasan: Zero initialize tag in __kasan_kmalloc' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).