All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pekka Enberg <penberg@cs.helsinki.fi>
To: hooanon05@yahoo.co.jp
Cc: Catalin Marinas <catalin.marinas@arm.com>, linux-kernel@vger.kernel.org
Subject: Re: Q, slab, kmemleak_erase() and redzone?
Date: Tue, 01 Dec 2009 13:49:55 +0200	[thread overview]
Message-ID: <4B1502E3.4000304@cs.helsinki.fi> (raw)
In-Reply-To: <6801.1259046382@jrobl>

hooanon05@yahoo.co.jp kirjoitti:
> Pekka Enberg:
>> We are setting an element in the per CPU array to NULL so the the
>> kmemleak code in ____cache_alloc() is safe. Red-zoning is done at the
>> _object_ which is not touched by kmemleak. Looking at the oops, it
>> does seem likely that you have a bug in your module (or in some other
>> part of the kernel).
> 
> Thanks for reply.
> In ____cache_alloc(), the variable 'ac' is assigned before
> cache_alloc_refill() call, and it is used for the parameter of
> kmemleak_erase(). The value may be changed by cache_alloc_refill(),
> isn't it?

No. The pointer returned by cpu_cache_get() is not changed by 
cache_alloc_refill(). The contents of the array might change, yes. That 
said, we should check if objp is NULL before calling kmemleak_erase(). 
Catalin?

> In this case, kmemleak_erase() receives the incorrect pointer and sets
> NULL to somewhere else which may be redzone?
> 
> How about this fix?
> If cpu_cache_get() call is heavy and we cannot ignore it when KMEMLEAK
> is disabled, then a new wrapper may be necessary.
> 
> diff --git a/mm/slab.c b/mm/slab.c
> index 71e0a1f..3f3e018 100644
> --- a/mm/slab.c
> +++ b/mm/slab.c
> @@ -3104,6 +3104,7 @@ static inline void *____cache_alloc(struct kmem_cache *cachep, gfp_t flags)
>  	} else {
>  		STATS_INC_ALLOCMISS(cachep);
>  		objp = cache_alloc_refill(cachep, flags);
> +		ac = cpu_cache_get(cachep);
>  	}
>  	/*
>  	 * To avoid a false negative, if an object that is in one of the
> 
> 
> 
> J. R. Okajima


  reply	other threads:[~2009-12-01 11:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-20 16:14 Q, slab, kmemleak_erase() and redzone? hooanon05
2009-11-22  9:35 ` Pekka Enberg
2009-11-24  7:06   ` hooanon05
2009-12-01 11:49     ` Pekka Enberg [this message]
2009-12-01 17:56       ` Catalin Marinas
2009-12-02  6:31         ` Pekka Enberg
2009-12-02  6:32           ` Pekka Enberg
2009-12-02  6:57             ` hooanon05
2009-12-02  7:01               ` Pekka Enberg
2009-12-02  3:21       ` hooanon05

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=4B1502E3.4000304@cs.helsinki.fi \
    --to=penberg@cs.helsinki.fi \
    --cc=catalin.marinas@arm.com \
    --cc=hooanon05@yahoo.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.