linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: Chen Jun <chenjun102@huawei.com>
Cc: cl@linux.com, penberg@kernel.org, rientjes@google.com,
	iamjoonsoo.kim@lge.com, akpm@linux-foundation.org,
	vbabka@suse.cz, roman.gushchin@linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, xuqiang36@huawei.com
Subject: Re: [PATCH] mm, slub: fix uninitialized variable in __slab_free
Date: Fri, 16 Dec 2022 16:42:32 +0900	[thread overview]
Message-ID: <Y5whaFO6Z1eaQzeu@hyeyoo> (raw)
In-Reply-To: <20221216033119.14159-1-chenjun102@huawei.com>

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


      reply	other threads:[~2022-12-16  7:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-16  3:31 Chen Jun
2022-12-16  7:42 ` Hyeonggon Yoo [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=Y5whaFO6Z1eaQzeu@hyeyoo \
    --to=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=chenjun102@huawei.com \
    --cc=cl@linux.com \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=vbabka@suse.cz \
    --cc=xuqiang36@huawei.com \
    /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