* [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix
@ 2016-07-15 16:50 ` Andrey Ryabinin
0 siblings, 0 replies; 4+ messages in thread
From: Andrey Ryabinin @ 2016-07-15 16:50 UTC (permalink / raw)
To: akpm
Cc: glider, dvyukov, iamjoonsoo.kim, kasan-dev, linux-mm,
linux-kernel, Andrey Ryabinin
- Remove CONFIG_SLAB ifdefs. The code works just fine with both allocators.
- Reset metada offsets if metadata doesn't fit. Otherwise kasan_metadata_size()
will give us the wrong results.
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
mm/kasan/kasan.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index d92a7a2..b6f99e8 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -372,9 +372,7 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
unsigned long *flags)
{
int redzone_adjust;
-#ifdef CONFIG_SLAB
int orig_size = *size;
-#endif
/* Add alloc meta. */
cache->kasan_info.alloc_meta_offset = *size;
@@ -392,25 +390,20 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
if (redzone_adjust > 0)
*size += redzone_adjust;
-#ifdef CONFIG_SLAB
- *size = min(KMALLOC_MAX_SIZE,
- max(*size,
- cache->object_size +
- optimal_redzone(cache->object_size)));
+ *size = min(KMALLOC_MAX_SIZE, max(*size, cache->object_size +
+ optimal_redzone(cache->object_size)));
+
/*
* If the metadata doesn't fit, don't enable KASAN at all.
*/
if (*size <= cache->kasan_info.alloc_meta_offset ||
*size <= cache->kasan_info.free_meta_offset) {
+ cache->kasan_info.alloc_meta_offset = 0;
+ cache->kasan_info.free_meta_offset = 0;
*size = orig_size;
return;
}
-#else
- *size = max(*size,
- cache->object_size +
- optimal_redzone(cache->object_size));
-#endif
*flags |= SLAB_KASAN;
}
--
2.7.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix
@ 2016-07-15 16:50 ` Andrey Ryabinin
0 siblings, 0 replies; 4+ messages in thread
From: Andrey Ryabinin @ 2016-07-15 16:50 UTC (permalink / raw)
To: akpm
Cc: glider, dvyukov, iamjoonsoo.kim, kasan-dev, linux-mm,
linux-kernel, Andrey Ryabinin
- Remove CONFIG_SLAB ifdefs. The code works just fine with both allocators.
- Reset metada offsets if metadata doesn't fit. Otherwise kasan_metadata_size()
will give us the wrong results.
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
mm/kasan/kasan.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
index d92a7a2..b6f99e8 100644
--- a/mm/kasan/kasan.c
+++ b/mm/kasan/kasan.c
@@ -372,9 +372,7 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
unsigned long *flags)
{
int redzone_adjust;
-#ifdef CONFIG_SLAB
int orig_size = *size;
-#endif
/* Add alloc meta. */
cache->kasan_info.alloc_meta_offset = *size;
@@ -392,25 +390,20 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
if (redzone_adjust > 0)
*size += redzone_adjust;
-#ifdef CONFIG_SLAB
- *size = min(KMALLOC_MAX_SIZE,
- max(*size,
- cache->object_size +
- optimal_redzone(cache->object_size)));
+ *size = min(KMALLOC_MAX_SIZE, max(*size, cache->object_size +
+ optimal_redzone(cache->object_size)));
+
/*
* If the metadata doesn't fit, don't enable KASAN at all.
*/
if (*size <= cache->kasan_info.alloc_meta_offset ||
*size <= cache->kasan_info.free_meta_offset) {
+ cache->kasan_info.alloc_meta_offset = 0;
+ cache->kasan_info.free_meta_offset = 0;
*size = orig_size;
return;
}
-#else
- *size = max(*size,
- cache->object_size +
- optimal_redzone(cache->object_size));
-#endif
*flags |= SLAB_KASAN;
}
--
2.7.3
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix
2016-07-15 16:50 ` Andrey Ryabinin
@ 2016-07-15 17:17 ` Alexander Potapenko
-1 siblings, 0 replies; 4+ messages in thread
From: Alexander Potapenko @ 2016-07-15 17:17 UTC (permalink / raw)
To: Andrey Ryabinin
Cc: Andrew Morton, Dmitriy Vyukov, Joonsoo Kim, kasan-dev,
Linux Memory Management List, LKML
On Fri, Jul 15, 2016 at 6:50 PM, Andrey Ryabinin
<aryabinin@virtuozzo.com> wrote:
> - Remove CONFIG_SLAB ifdefs. The code works just fine with both allocators.
> - Reset metada offsets if metadata doesn't fit. Otherwise kasan_metadata_size()
> will give us the wrong results.
>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Alexander Potapenko <glider@google.com>
> ---
> mm/kasan/kasan.c | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index d92a7a2..b6f99e8 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -372,9 +372,7 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
> unsigned long *flags)
> {
> int redzone_adjust;
> -#ifdef CONFIG_SLAB
> int orig_size = *size;
> -#endif
>
> /* Add alloc meta. */
> cache->kasan_info.alloc_meta_offset = *size;
> @@ -392,25 +390,20 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
> if (redzone_adjust > 0)
> *size += redzone_adjust;
>
> -#ifdef CONFIG_SLAB
> - *size = min(KMALLOC_MAX_SIZE,
> - max(*size,
> - cache->object_size +
> - optimal_redzone(cache->object_size)));
> + *size = min(KMALLOC_MAX_SIZE, max(*size, cache->object_size +
> + optimal_redzone(cache->object_size)));
> +
> /*
> * If the metadata doesn't fit, don't enable KASAN at all.
> */
> if (*size <= cache->kasan_info.alloc_meta_offset ||
> *size <= cache->kasan_info.free_meta_offset) {
> + cache->kasan_info.alloc_meta_offset = 0;
> + cache->kasan_info.free_meta_offset = 0;
> *size = orig_size;
> return;
> }
> -#else
> - *size = max(*size,
> - cache->object_size +
> - optimal_redzone(cache->object_size));
>
> -#endif
> *flags |= SLAB_KASAN;
> }
>
> --
> 2.7.3
>
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix
@ 2016-07-15 17:17 ` Alexander Potapenko
0 siblings, 0 replies; 4+ messages in thread
From: Alexander Potapenko @ 2016-07-15 17:17 UTC (permalink / raw)
To: Andrey Ryabinin
Cc: Andrew Morton, Dmitriy Vyukov, Joonsoo Kim, kasan-dev,
Linux Memory Management List, LKML
On Fri, Jul 15, 2016 at 6:50 PM, Andrey Ryabinin
<aryabinin@virtuozzo.com> wrote:
> - Remove CONFIG_SLAB ifdefs. The code works just fine with both allocators.
> - Reset metada offsets if metadata doesn't fit. Otherwise kasan_metadata_size()
> will give us the wrong results.
>
> Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Alexander Potapenko <glider@google.com>
> ---
> mm/kasan/kasan.c | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/mm/kasan/kasan.c b/mm/kasan/kasan.c
> index d92a7a2..b6f99e8 100644
> --- a/mm/kasan/kasan.c
> +++ b/mm/kasan/kasan.c
> @@ -372,9 +372,7 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
> unsigned long *flags)
> {
> int redzone_adjust;
> -#ifdef CONFIG_SLAB
> int orig_size = *size;
> -#endif
>
> /* Add alloc meta. */
> cache->kasan_info.alloc_meta_offset = *size;
> @@ -392,25 +390,20 @@ void kasan_cache_create(struct kmem_cache *cache, size_t *size,
> if (redzone_adjust > 0)
> *size += redzone_adjust;
>
> -#ifdef CONFIG_SLAB
> - *size = min(KMALLOC_MAX_SIZE,
> - max(*size,
> - cache->object_size +
> - optimal_redzone(cache->object_size)));
> + *size = min(KMALLOC_MAX_SIZE, max(*size, cache->object_size +
> + optimal_redzone(cache->object_size)));
> +
> /*
> * If the metadata doesn't fit, don't enable KASAN at all.
> */
> if (*size <= cache->kasan_info.alloc_meta_offset ||
> *size <= cache->kasan_info.free_meta_offset) {
> + cache->kasan_info.alloc_meta_offset = 0;
> + cache->kasan_info.free_meta_offset = 0;
> *size = orig_size;
> return;
> }
> -#else
> - *size = max(*size,
> - cache->object_size +
> - optimal_redzone(cache->object_size));
>
> -#endif
> *flags |= SLAB_KASAN;
> }
>
> --
> 2.7.3
>
--
Alexander Potapenko
Software Engineer
Google Germany GmbH
Erika-Mann-Straße, 33
80636 München
Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-07-16 0:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-15 16:50 [PATCH] mm-kasan-switch-slub-to-stackdepot-enable-memory-quarantine-for-slub-fix Andrey Ryabinin
2016-07-15 16:50 ` Andrey Ryabinin
2016-07-15 17:17 ` Alexander Potapenko
2016-07-15 17:17 ` Alexander Potapenko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.