linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
To: glider@google.com
Cc: walter-zh.wu@mediatek.com, dvyukov@google.com,
	gregkh@linuxfoundation.org, akpm@linux-foundation.org,
	matthias.bgg@gmail.com, tglx@linutronix.de, jpoimboe@redhat.com,
	kstewart@linuxfoundation.org, linux-mm@kvack.org
Subject: Re: [PATCH] lib/stackdepot: fix global out-of-bounds in stack_slabs
Date: Mon, 3 Feb 2020 20:02:26 +0900	[thread overview]
Message-ID: <f2adce7f-3f2f-60d4-4dea-3b146b9d35f5@I-love.SAKURA.ne.jp> (raw)
In-Reply-To: <20200203102953.17349-1-glider@google.com>

On 2020/02/03 19:29, glider@google.com wrote:
> --- a/lib/stackdepot.c
> +++ b/lib/stackdepot.c
> @@ -84,7 +84,9 @@ static bool init_stack_slab(void **prealloc)
>  	if (stack_slabs[depot_index] == NULL) {
>  		stack_slabs[depot_index] = *prealloc;
>  	} else {
> -		stack_slabs[depot_index + 1] = *prealloc;
> +		/* If this is the last depot slab, do not touch the next one. */
> +		if (depot_index + 1 < STACK_ALLOC_MAX_SLABS)
> +			stack_slabs[depot_index + 1] = *prealloc;

What prevents memory leak (caused by "*prealloc = NULL;")
when we hit depot_index + 1 >= STACK_ALLOC_MAX_SLABS condition?

>  		/*
>  		 * This smp_store_release pairs with smp_load_acquire() from
>  		 * |next_slab_inited| above and in stack_depot_save().
> 


  reply	other threads:[~2020-02-03 11:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-03 10:29 glider
2020-02-03 11:02 ` Tetsuo Handa [this message]
2020-02-03 11:10   ` Alexander Potapenko
2020-02-18 10:29 glider
2020-02-19 21:37 ` Andrew Morton

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=f2adce7f-3f2f-60d4-4dea-3b146b9d35f5@I-love.SAKURA.ne.jp \
    --to=penguin-kernel@i-love.sakura.ne.jp \
    --cc=akpm@linux-foundation.org \
    --cc=dvyukov@google.com \
    --cc=glider@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jpoimboe@redhat.com \
    --cc=kstewart@linuxfoundation.org \
    --cc=linux-mm@kvack.org \
    --cc=matthias.bgg@gmail.com \
    --cc=tglx@linutronix.de \
    --cc=walter-zh.wu@mediatek.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