linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm, slub: fix uninitialized variable in __slab_free
@ 2022-12-16  3:31 Chen Jun
  2022-12-16  7:42 ` Hyeonggon Yoo
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Jun @ 2022-12-16  3:31 UTC (permalink / raw)
  To: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka,
	roman.gushchin, 42.hyeyoo, linux-mm, linux-kernel
  Cc: xuqiang36

new.frozen is not initialized before it is used.

Fixes: 2cfb7455d223 ("slub: Rework allocator fastpaths")
Signed-off-by: Chen Jun <chenjun102@huawei.com>
---
 mm/slub.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/mm/slub.c b/mm/slub.c
index 13459c69095a..8628c88875b6 100644
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3593,6 +3593,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
 		return;
 	}
 
+	new.frozen = 0;
 	do {
 		if (unlikely(n)) {
 			spin_unlock_irqrestore(&n->list_lock, flags);
-- 
2.17.1



^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm, slub: fix uninitialized variable in __slab_free
  2022-12-16  3:31 [PATCH] mm, slub: fix uninitialized variable in __slab_free Chen Jun
@ 2022-12-16  7:42 ` Hyeonggon Yoo
  0 siblings, 0 replies; 2+ messages in thread
From: Hyeonggon Yoo @ 2022-12-16  7:42 UTC (permalink / raw)
  To: Chen Jun
  Cc: cl, penberg, rientjes, iamjoonsoo.kim, akpm, vbabka,
	roman.gushchin, linux-mm, linux-kernel, xuqiang36

On Fri, Dec 16, 2022 at 03:31:19AM +0000, Chen Jun wrote:
> new.frozen is not initialized before it is used.
> 
> Fixes: 2cfb7455d223 ("slub: Rework allocator fastpaths")
> Signed-off-by: Chen Jun <chenjun102@huawei.com>
> ---
>  mm/slub.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/mm/slub.c b/mm/slub.c
> index 13459c69095a..8628c88875b6 100644
> --- a/mm/slub.c
> +++ b/mm/slub.c
> @@ -3593,6 +3593,7 @@ static void __slab_free(struct kmem_cache *s, struct slab *slab,
>  		return;
>  	}
>  
> +	new.frozen = 0;
>  	do {
>  		if (unlikely(n)) {
>  			spin_unlock_irqrestore(&n->list_lock, flags);
> -- 
> 2.17.1

This is incorrect because new.frozen is initialized when new.counters is
initialized.

See definition of struct slab in mm/slab.h:

struct slab {

	[...]
	union {
		unsigned long counters;
		struct {
			unsigned inuse:16;
			unsigned objects:15;
			unsigned frozen:1;
		};
	};
}

-- 
Thanks,
Hyeonggon


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-16  7:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-16  3:31 [PATCH] mm, slub: fix uninitialized variable in __slab_free Chen Jun
2022-12-16  7:42 ` Hyeonggon Yoo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox