Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1323801 > unrolled thread

Re: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test

Started byAndrew Morton <akpm@linux-foundation.org>
First post2016-02-02 06:40 +0100
Last post2016-02-02 17:30 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [PATCH v1 1/8] kasan: Change the behavior of  kmalloc_large_oob_right test Andrew Morton <akpm@linux-foundation.org> - 2016-02-02 06:40 +0100
    Re: [PATCH v1 1/8] kasan: Change the behavior of  kmalloc_large_oob_right test Andrey Ryabinin <ryabinin.a.a@gmail.com> - 2016-02-02 16:30 +0100
      Re: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right  test Alexander Potapenko <glider@google.com> - 2016-02-02 17:30 +0100

#1323801 — Re: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test

FromAndrew Morton <akpm@linux-foundation.org>
Date2016-02-02 06:40 +0100
SubjectRe: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test
Message-ID<qXBQZ-66V-9@gated-at.bofh.it>
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.

[toc] | [next] | [standalone]


#1324195

FromAndrey Ryabinin <ryabinin.a.a@gmail.com>
Date2016-02-02 16:30 +0100
Message-ID<qXL3Y-4VX-7@gated-at.bofh.it>
In reply to#1323801

On 02/02/2016 08:34 AM, Andrew Morton wrote:
> 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.
> 

Actually it would be simpler to not use KMALLOC_MAX_CACHE_SIZE at all.
Simply replace it with 2 or 3 PAGE_SIZEs.

[toc] | [prev] | [next] | [standalone]


#1324254 — Re: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test

FromAlexander Potapenko <glider@google.com>
Date2016-02-02 17:30 +0100
SubjectRe: [PATCH v1 1/8] kasan: Change the behavior of kmalloc_large_oob_right test
Message-ID<qXM03-5FW-23@gated-at.bofh.it>
In reply to#1324195
The intention was to detect the situation in which a new allocator
appears for which we don't know how it behaves if we allocate more
than KMALLOC_MAX_CACHE_SIZE.
I agree this makes little sense and we can just stick to
CONFIG_SLAB/CONFIG_SLUB cases.

However I think it's better to keep 'size = KMALLOC_MAX_CACHE_SIZE +
something' to keep this code working in the case the value of
KMALLOC_MAX_CACHE_SIZE changes.

On Tue, Feb 2, 2016 at 4:29 PM, Andrey Ryabinin <ryabinin.a.a@gmail.com> wrote:
>
>
> On 02/02/2016 08:34 AM, Andrew Morton wrote:
>> 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.
>>
>
> Actually it would be simpler to not use KMALLOC_MAX_CACHE_SIZE at all.
> Simply replace it with 2 or 3 PAGE_SIZEs.



-- 
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
Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat sind,
leiten Sie diese bitte nicht weiter, informieren Sie den
Absender und löschen Sie die E-Mail und alle Anhänge. Vielen Dank.
This e-mail is confidential. If you are not the right addressee please
do not forward it, please inform the sender, and please erase this
e-mail including any attachments. Thanks.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web