Commit 772a2fa5 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Linus Torvalds
Browse files

kasan, mm: perform untagged pointers comparison in krealloc

The krealloc function checks where the same buffer was reused or a new one
allocated by comparing kernel pointers.  Tag-based KASAN changes memory
tag on the krealloc'ed chunk of memory and therefore also changes the
pointer tag of the returned pointer.  Therefore we need to perform
comparison on untagged (with tags reset) pointers to check whether it's
the same memory region or not.


Signed-off-by: default avatarAndrey Konovalov <>
Reviewed-by: default avatarAndrey Ryabinin <>
Reviewed-by: default avatarDmitry Vyukov <>
Cc: Christoph Lameter <>
Cc: Mark Rutland <>
Cc: Will Deacon <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 21696c16
......@@ -1534,7 +1534,7 @@ void *krealloc(const void *p, size_t new_size, gfp_t flags)
ret = __do_krealloc(p, new_size, flags);
if (ret && p != ret)
if (ret && kasan_reset_tag(p) != kasan_reset_tag(ret))
return ret;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment