Commit d17ee296 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Stephen Rothwell
Browse files

kasan: don't round_up too much

For hardware tag-based mode kasan_poison_memory() already rounds up the
size. Do the same for software modes and remove round_up() from the common


Signed-off-by: default avatarAndrey Konovalov <>
Reviewed-by: default avatarDmitry Vyukov <>
Reviewed-by: default avatarMarco Elver <>
Tested-by: Vincenzo Frascino's avatarVincenzo Frascino <>
Cc: Alexander Potapenko <>
Cc: Andrey Ryabinin <>
Cc: Branislav Rankov <>
Cc: Catalin Marinas <>
Cc: Evgenii Stepanov <>
Cc: Kevin Brodsky <>
Cc: Vasily Gorbik <>
Cc: Will Deacon <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarStephen Rothwell <>
parent 23140153
......@@ -214,9 +214,7 @@ void __kasan_unpoison_object_data(struct kmem_cache *cache, void *object)
void __kasan_poison_object_data(struct kmem_cache *cache, void *object)
round_up(cache->object_size, KASAN_GRANULE_SIZE),
poison_range(object, cache->object_size, KASAN_KMALLOC_REDZONE);
......@@ -289,7 +287,6 @@ static bool ____kasan_slab_free(struct kmem_cache *cache, void *object,
u8 tag;
void *tagged_object;
unsigned long rounded_up_size;
tag = get_tag(object);
tagged_object = object;
......@@ -313,8 +310,7 @@ static bool ____kasan_slab_free(struct kmem_cache *cache, void *object,
return true;
rounded_up_size = round_up(cache->object_size, KASAN_GRANULE_SIZE);
poison_range(object, rounded_up_size, KASAN_KMALLOC_FREE);
poison_range(object, cache->object_size, KASAN_KMALLOC_FREE);
if (!kasan_stack_collection_enabled())
return false;
......@@ -83,6 +83,7 @@ void poison_range(const void *address, size_t size, u8 value)
* addresses to this function.
address = kasan_reset_tag(address);
size = round_up(size, KASAN_GRANULE_SIZE);
/* Skip KFENCE memory if called explicitly outside of sl*b. */
if (is_kfence_address(address))
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