Re: [PATCH v4 1/3] lib/test_kasan: Add bitops tests

From: Andrey Ryabinin
Date: Thu Jun 13 2019 - 11:26:05 EST




On 6/13/19 3:30 PM, Marco Elver wrote:
> This adds bitops tests to the test_kasan module. In a follow-up patch,
> support for bitops instrumentation will be added.
>
> Signed-off-by: Marco Elver <elver@xxxxxxxxxx>
> Acked-by: Mark Rutland <mark.rutland@xxxxxxx>
> ---

Reviewed-by: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx>




> +static noinline void __init kasan_bitops(void)
> +{
> + /*
> + * Allocate 1 more byte, which causes kzalloc to round up to 16-bytes;
> + * this way we do not actually corrupt other memory, in case
> + * instrumentation is not working as intended.

This sound like working instrumentation somehow save us from corrupting memory. In fact it doesn't,
it only reports corruption.

> + */
> + long *bits = kzalloc(sizeof(*bits) + 1, GFP_KERNEL);
> + if (!bits)
> + return;
> +