lkml.org 
[lkml]   [2009]   [Aug]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (f6f6e1a4), by kmemleak's scan_block()
From
Date
On Tue, 2009-08-25 at 12:11 +0300, Pekka Enberg wrote:
> On Tue, 2009-08-25 at 11:03 +0200, Vegard Nossum wrote:
> > I don't know so much about the kmemleak internals, but this I can say
> > about the kmemcheck part: According to your definition, an object is
> > initialized if all the bytes of an object are initialized.
> >
> > Is it possible that because of this, if we have a partially
> > uninitialized object, kmemleak will not record the pointers found in
> > that object? If so, it might skip valid pointers, and deem an object
> > unreferenced. Which could make kmemleak give false-positives.
> >
> > I think it would be better to ask kmemcheck on a per-pointer basis
> > (i.e. for each pointer-sized word in the object), whether it is
> > initialized or not.
>
> Yeah, makes sense.

I think this patch should work. With a few minor (aesthetic) things
below and assuming that Ingo tests it (I don't have x86 hardware at hand
now):

Acked-by: Catalin Marinas <catalin.marinas@arm.com>

> @@ -885,7 +886,8 @@ static void scan_block(void *_start, void *_end,
>
> for (ptr = start; ptr < end; ptr++) {
> unsigned long flags;
> - unsigned long pointer = *ptr;
> + unsigned long pointer;
> +
> struct kmemleak_object *object;

An empty line here added which splits the local variables block.

> if (allow_resched)
> @@ -893,6 +895,13 @@ static void scan_block(void *_start, void *_end,
> if (scan_should_stop())
> break;
>
> + /* Don't scan uninitialized memory. */
> + if (!kmemcheck_is_obj_initialized((unsigned long) ptr,
> + sizeof(unsigned long)))

There is a BYTES_PER_POINTER macro defined in the kmemleak.c file, you
could use that instead of sizeof(unsigned long).

Thanks.

--
Catalin



\
 
 \ /
  Last update: 2009-08-25 11:23    [W:0.059 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site