Skip to content

Commit

Permalink
kasan: initialize tag to 0xff in __kasan_kmalloc
Browse files Browse the repository at this point in the history
When building with -Wuninitialized and CONFIG_KASAN_SW_TAGS unset, Clang
warns:

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.  Initialize tag to 0xff, as it removes
this warning and doesn't change the meaning of the code.

Link: ClangBuiltLinux#465
Link: http://lkml.kernel.org/r/[email protected]
Fixes: 7f94ffb ("kasan: add hooks implementation for tag-based mode")
Signed-off-by: Nathan Chancellor <[email protected]>
Reviewed-by: Andrey Konovalov <[email protected]>
Reviewed-by: Andrey Ryabinin <[email protected]>
Cc: Alexander Potapenko <[email protected]>
Cc: Dmitry Vyukov <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
nathanchance authored and torvalds committed Jun 1, 2019
1 parent bb9f6f6 commit 0600597
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mm/kasan/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 0xff;

if (gfpflags_allow_blocking(flags))
quarantine_reduce();
Expand Down

0 comments on commit 0600597

Please sign in to comment.