[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c7b03b1e-e000-279d-f845-5808653ac3bf@gentwo.org>
Date: Fri, 11 Oct 2024 11:07:44 -0700 (PDT)
From: "Christoph Lameter (Ampere)" <cl@...two.org>
To: "yuan.gao" <yuan.gao@...oud.cn>
cc: penberg@...nel.org, rientjes@...gle.com, iamjoonsoo.kim@....com,
akpm@...ux-foundation.org, vbabka@...e.cz, roman.gushchin@...ux.dev,
42.hyeyoo@...il.com, linux-mm@...ck.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v3] mm/slub: Avoid list corruption when removing a slab
from the full list
On Fri, 11 Oct 2024, yuan.gao wrote:
> When an object belonging to the slab got freed later, the remove_full()
> function is called. Because the slab is neither on the partial list nor
> on the full list, it eventually lead to a list corruption.
We detect list poison....
> diff --git a/mm/slab.h b/mm/slab.h
> index 6c6fe6d630ce..7681e71d9a13 100644
> --- a/mm/slab.h
> +++ b/mm/slab.h
> @@ -73,6 +73,10 @@ struct slab {
> struct {
> unsigned inuse:16;
> unsigned objects:15;
> + /*
> + * Reuse frozen bit for slab with debug enabled:
"If slab debugging is enabled then the frozen bit can bereused to
indicate that the slab was corrupted"
> index 5b832512044e..b9265e9f11aa 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -1423,6 +1423,11 @@ static int check_slab(struct kmem_cache *s, struct slab *slab)
> slab->inuse, slab->objects);
> return 0;
> }
> + if (slab->frozen) {
> + slab_err(s, slab, "Corrupted slab");
"Slab folio disabled due to metadata corruption" ?
> @@ -2744,7 +2750,10 @@ static void *alloc_single_from_partial(struct kmem_cache *s,
> slab->inuse++;
>
> if (!alloc_debug_processing(s, slab, object, orig_size)) {
> - remove_partial(n, slab);
> + if (folio_test_slab(slab_folio(slab))) {
Does folio_test_slab test for the frozen bit??
Powered by blists - more mailing lists