mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Guenter Roeck <linux@roeck-us.net>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Oliver Glitta <glittao@gmail.com>,
	Daniel Latypov <dlatypov@google.com>,
	Marco Elver <elver@google.com>
Subject: Re: [PATCH] mm/slub, kunit: Use inverted data to corrupt kmem cache
Date: Thu, 4 Apr 2024 16:20:24 +0200	[thread overview]
Message-ID: <dc25b95b-8515-4108-94e3-d83e6948b861@suse.cz> (raw)
In-Reply-To: <20240402133839.283793-1-linux@roeck-us.net>

On 4/2/24 3:38 PM, Guenter Roeck wrote:
> Two failure patterns are seen randomly when running slub_kunit tests with
> CONFIG_SLAB_FREELIST_RANDOM and CONFIG_SLAB_FREELIST_HARDENED enabled.
> 
> Pattern 1:
>      # test_clobber_zone: pass:1 fail:0 skip:0 total:1
>      ok 1 test_clobber_zone
>      # test_next_pointer: EXPECTATION FAILED at lib/slub_kunit.c:72
>      Expected 3 == slab_errors, but
>          slab_errors == 0 (0x0)
>      # test_next_pointer: EXPECTATION FAILED at lib/slub_kunit.c:84
>      Expected 2 == slab_errors, but
>          slab_errors == 0 (0x0)
>      # test_next_pointer: pass:0 fail:1 skip:0 total:1
>      not ok 2 test_next_pointer
> 
> In this case, test_next_pointer() overwrites p[s->offset], but the data
> at p[s->offset] is already 0x12.
> 
> Pattern 2:
>      ok 1 test_clobber_zone
>      # test_next_pointer: EXPECTATION FAILED at lib/slub_kunit.c:72
>      Expected 3 == slab_errors, but
>          slab_errors == 2 (0x2)
>      # test_next_pointer: pass:0 fail:1 skip:0 total:1
>      not ok 2 test_next_pointer
> 
> In this case, p[s->offset] has a value other than 0x12, but one of the
> expected failures is nevertheless missing.
> 
> Invert data instead of writing a fixed value to corrupt the cache data
> structures to fix the problem.
> 
> Fixes: 1f9f78b1b376 ("mm/slub, kunit: add a KUnit test for SLUB debugging functionality")
> Cc: Oliver Glitta <glittao@gmail.com>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> CC: Daniel Latypov <dlatypov@google.com>
> Cc: Marco Elver <elver@google.com>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Added to slab/for-next, thanks.

> ---
>  lib/slub_kunit.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/slub_kunit.c b/lib/slub_kunit.c
> index d4a3730b08fa..4ce960438806 100644
> --- a/lib/slub_kunit.c
> +++ b/lib/slub_kunit.c
> @@ -55,7 +55,7 @@ static void test_next_pointer(struct kunit *test)
>  
>  	ptr_addr = (unsigned long *)(p + s->offset);
>  	tmp = *ptr_addr;
> -	p[s->offset] = 0x12;
> +	p[s->offset] = ~p[s->offset];
>  
>  	/*
>  	 * Expecting three errors.


      reply	other threads:[~2024-04-04 14:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-02 13:38 Guenter Roeck
2024-04-04 14:20 ` Vlastimil Babka [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dc25b95b-8515-4108-94e3-d83e6948b861@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=dlatypov@google.com \
    --cc=elver@google.com \
    --cc=glittao@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®