[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZlXWlrjdZpoD4bS9@feng-clx.sh.intel.com>
Date: Tue, 28 May 2024 21:05:26 +0800
From: Feng Tang <feng.tang@...el.com>
To: Chengming Zhou <chengming.zhou@...ux.dev>
CC: Christoph Lameter <cl@...ux.com>, Pekka Enberg <penberg@...nel.org>, David
Rientjes <rientjes@...gle.com>, Joonsoo Kim <iamjoonsoo.kim@....com>, Andrew
Morton <akpm@...ux-foundation.org>, Vlastimil Babka <vbabka@...e.cz>, Roman
Gushchin <roman.gushchin@...ux.dev>, Hyeonggon Yoo <42.hyeyoo@...il.com>,
<linux-mm@...ck.org>, <linux-kernel@...r.kernel.org>,
<zhouchengming@...edance.com>
Subject: Re: [PATCH 2/3] slab: don't put freepointer outside of object if
only orig_size
On Tue, May 28, 2024 at 03:16:47PM +0800, Chengming Zhou wrote:
> The commit 946fa0dbf2d8 ("mm/slub: extend redzone check to extra
> allocated kmalloc space than requested") will extend right redzone
> when allocating for orig_size < object_size. So we can't overlay the
> freepointer in the object space in this case.
>
> But the code looks like it forgot to check SLAB_RED_ZONE, since there
> won't be extended right redzone if only orig_size enabled.
Look good to me. Thanks!
Reviewed-by: Feng Tang <feng.tang@...el.com>
>
> Signed-off-by: Chengming Zhou <chengming.zhou@...ux.dev>
> ---
> mm/slub.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/slub.c b/mm/slub.c
> index de57512734ac..b92d9a557852 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -5150,7 +5150,7 @@ static int calculate_sizes(struct kmem_cache *s)
> */
> s->inuse = size;
>
> - if (slub_debug_orig_size(s) ||
> + if (((flags & SLAB_RED_ZONE) && slub_debug_orig_size(s)) ||
> (flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) ||
> ((flags & SLAB_RED_ZONE) && s->object_size < sizeof(void *)) ||
> s->ctor) {
>
> --
> 2.45.1
>
Powered by blists - more mailing lists