lkml.org 
[lkml]   [2016]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test
On Wed, 27 Jan 2016 19:25:06 +0100 Alexander Potapenko <glider@google.com> wrote:

> depending on which allocator (SLAB or SLUB) is being used
>
> ...
>
> --- a/lib/test_kasan.c
> +++ b/lib/test_kasan.c
> @@ -68,7 +68,22 @@ static noinline void __init kmalloc_node_oob_right(void)
> static noinline void __init kmalloc_large_oob_right(void)
> {
> char *ptr;
> - size_t size = KMALLOC_MAX_CACHE_SIZE + 10;
> + size_t size;
> +
> + if (KMALLOC_MAX_CACHE_SIZE == KMALLOC_MAX_SIZE) {
> + /*
> + * We're using the SLAB allocator. Allocate a chunk that fits
> + * into a slab.
> + */
> + size = KMALLOC_MAX_CACHE_SIZE - 256;
> + } else {
> + /*
> + * KMALLOC_MAX_SIZE > KMALLOC_MAX_CACHE_SIZE.
> + * We're using the SLUB allocator. Allocate a chunk that does
> + * not fit into a slab to trigger the page allocator.
> + */
> + size = KMALLOC_MAX_CACHE_SIZE + 10;
> + }

This seems a weird way of working out whether we're using SLAB or SLUB.

Can't we use, umm, #ifdef CONFIG_SLAB? If not that then let's cook up
something standardized rather than a weird just-happens-to-work like
this.


\
 
 \ /
  Last update: 2016-02-02 06:41    [W:2.373 / U:1.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site