kasan: Zero initialize tag in __kasan_kmalloc
Subsystems (2)
PATCH 1/1 kasan: Zero initialize tag in __kasan_kmalloc
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. Just zero initialize tag, as it removes this warning and doesn't change the meaning of the code.
--- mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kasan/common.c +1 -1
@@ -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))quarantine_reduce ();
Signature · 1 line
2.21.0
Quoted 26 lines · Nathan Chancellor
When building with -Wuninitialized and
CONFIG_KASAN_SW_TAGSunset, 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_tagignores tag in this configuration but clang doesn't realize it at this point in its pipeline, as it points toarch_kasan_set_tagas 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 <[email protected]>--- mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/kasan/common.c +0
-0
mm/kasan/common.c static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object, · line 467
Quoted 5 lines
mm/kasan/common.c +1
-1@@ -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 ;
Hi Nathan,
Could you change this value to 0xff? This doesn't make any difference, since set_tag() ignores the tag anyway, but is less confusing, as all the non-tagged kernel pointers have 0xff in the top byte.
Thanks!
Quoted 12 lines
mm/kasan/common.c +0
-1if (gfpflags_allow_blocking (flags))quarantine_reduce (); --2.21.0
--
You received this message because you are subscribed to the Google Groups "kasan-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20190502153538.2326-1-natechancellor%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
PATCH v2 1/1 kasan: Initialize tag to 0xff in __kasan_kmalloc
In reply to Nathan ChancellorWhen 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.
---
v1 -> v2:
* Initialize tag to 0xff at Andrey's request
mm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/kasan/common.c +1 -1
@@ -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 ();
Signature · 1 line
2.21.0
Re: [PATCH v2] kasan: Initialize tag to 0xff in __kasan_kmalloc
Quoted 9 lines · Nathan Chancellor
When building with -Wuninitialized and
CONFIG_KASAN_SW_TAGSunset, 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); ^~~
Quoted 8 lines
set_tagignores tag in this configuration but clang doesn't realize it at this point in its pipeline, as it points toarch_kasan_set_tagas being the point where it is used, which will later be expanded to (void *)(object) without a use of tag. Initialize tag to0xff, as it removes this warning and doesn't change the meaning of the code.
Thanks!
Quoted 31 lines
---
v1 -> v2:
* Initialize tag to
0xffat Andrey's requestmm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/kasan/common.c +1
-2@@ -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 (); --2.21.0
--
You received this message because you are subscribed to the Google Groups "kasan-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20190502163057.6603-1-natechancellor%40gmail.com.
For more options, visit https://groups.google.com/d/optout.
Re: [PATCH v2] kasan: Initialize tag to 0xff in __kasan_kmalloc
Quoted 17 lines · Andrey Konovalov
Quoted 15 lines · Nathan Chancellor
When building with -Wuninitialized and
CONFIG_KASAN_SW_TAGSunset, 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_tagignores tag in this configuration but clang doesn't realize it at this point in its pipeline, as it points toarch_kasan_set_tagas being the point where it is used, which will later be expanded to (void *)(object) without a use of tag. Initialize tag to0xff, as it removes this warning and doesn't change the meaning of the code.
Quoted 7 lines
Quoted 2 lines
Reviewed-by Andrey Konovalov <[email protected]>Thanks!
Thanks Andrey! Did anyone else have any other comments or can this be picked up?
Cheers,
Nathan
Re: [PATCH v2] kasan: Initialize tag to 0xff in __kasan_kmalloc
In reply to Nathan ChancellorQuoted 8 lines · Nathan Chancellor
When building with -Wuninitialized and
CONFIG_KASAN_SW_TAGSunset, 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); ^~~
Quoted 8 lines
set_tagignores tag in this configuration but clang doesn't realize it at this point in its pipeline, as it points toarch_kasan_set_tagas being the point where it is used, which will later be expanded to (void *)(object) without a use of tag. Initialize tag to0xff, as it removes this warning and doesn't change the meaning of the code.
Quoted 23 lines
---
v1 -> v2:
* Initialize tag to
0xffat Andrey's requestmm/kasan/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/kasan/common.c +1
-1@@ -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 ();