linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Rientjes <rientjes@google.com>
To: Suresh Jayaraman <sjayaraman@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	netdev@vger.kernel.org, Neil Brown <neilb@suse.de>,
	Miklos Szeredi <mszeredi@suse.cz>, Wouter Verhelst <w@uter.be>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	trond.myklebust@fys.uio.no
Subject: Re: [PATCH 30/31] Fix use of uninitialized variable in cache_grow()
Date: Thu, 1 Oct 2009 13:49:00 -0700 (PDT)	[thread overview]
Message-ID: <alpine.DEB.1.00.0910011341280.27559@chino.kir.corp.google.com> (raw)
In-Reply-To: <1254406257-16735-1-git-send-email-sjayaraman@suse.de>

On Thu, 1 Oct 2009, Suresh Jayaraman wrote:

> From: Miklos Szeredi <mszeredi@suse.cz>
> 
> This fixes a bug in reserve-slub.patch.
> 
> If cache_grow() was called with objp != NULL then the 'reserve' local
> variable wasn't initialized. This resulted in ac->reserve being set to
> a rubbish value.  Due to this in some circumstances huge amounts of
> slab pages were allocated (due to slab_force_alloc() returning true),
> which caused atomic page allocation failures and slowdown of the
> system.
> 
> Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
> Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
> ---
>  mm/slab.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> Index: mmotm/mm/slab.c
> ===================================================================
> --- mmotm.orig/mm/slab.c
> +++ mmotm/mm/slab.c
> @@ -2760,7 +2760,7 @@ static int cache_grow(struct kmem_cache
>  	size_t offset;
>  	gfp_t local_flags;
>  	struct kmem_list3 *l3;
> -	int reserve;
> +	int reserve = -1;
>  
>  	/*
>  	 * Be lazy and only check for valid flags here,  keeping it out of the
> @@ -2816,7 +2816,8 @@ static int cache_grow(struct kmem_cache
>  	if (local_flags & __GFP_WAIT)
>  		local_irq_disable();
>  	check_irq_off();
> -	slab_set_reserve(cachep, reserve);
> +	if (reserve != -1)
> +		slab_set_reserve(cachep, reserve);
>  	spin_lock(&l3->list_lock);
>  
>  	/* Make slab active. */

Given the patch description, shouldn't this be a test for objp != NULL 
instead, then?

If so, it doesn't make sense because reserve will only be initialized when 
objp == NULL in the call to kmem_getpages() from cache_grow().


The title of the patch suggests this is just dealing with an uninitialized 
auto variable so the anticipated change would be from "int reserve" to 
"int uninitialized_var(result)".

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2009-10-01 20:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-01 14:10 Suresh Jayaraman
2009-10-01 20:49 ` David Rientjes [this message]
2009-10-02  4:54   ` Neil Brown
2009-10-02 10:05     ` David Rientjes

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=alpine.DEB.1.00.0910011341280.27559@chino.kir.corp.google.com \
    --to=rientjes@google.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mszeredi@suse.cz \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=sjayaraman@suse.de \
    --cc=torvalds@linux-foundation.org \
    --cc=trond.myklebust@fys.uio.no \
    --cc=w@uter.be \
    /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