mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: roel kluin <roel.kluin@gmail.com>
To: Catalin Marinas <catalin.marinas@arm.com>
Cc: linux-kernel@vger.kernel.org, Vegard Nossum <vegardno@ifi.uio.no>,
	Andrew Morton <akpm@linux-foundation.org>,
	Pekka Enberg <penberg@cs.helsinki.fi>,
	Christian Casteyde <casteyde.christian@free.fr>
Subject: Re: [PATCH] kmemcheck: Test the full object in kmemcheck_is_obj_initialized()
Date: Mon, 8 Feb 2010 15:38:09 +0100	[thread overview]
Message-ID: <25e057c01002080638g149c974r759f50365cd05233@mail.gmail.com> (raw)
In-Reply-To: <20100208111624.5387.37948.stgit@pc1117.cambridge.arm.com>

On Mon, Feb 8, 2010 at 12:16 PM, Catalin Marinas
<catalin.marinas@arm.com> wrote:
> This is a fix for bug #14845 (bugzilla.kernel.org). The
> update_checksum() function in mm/kmemleak.c calls
> kmemcheck_is_obj_initialised() before scanning an object. When
> KMEMCHECK_PARTIAL_OK is enabled, this function returns true. However,
> the crc32_le() reads smaller intervals (32-bit) for which
> kmemleak_is_obj_initialised() may be false leading to a kmemcheck
> warning.
>
> Note that kmemcheck_is_obj_initialized() is currently only used by
> kmemleak before scanning a memory location.

>  enum kmemcheck_shadow kmemcheck_shadow_test(void *shadow, unsigned int size)
>  {
> +#ifdef CONFIG_KMEMCHECK_PARTIAL_OK
>        uint8_t *x;
>        unsigned int i;
>
>        x = shadow;
>
> -#ifdef CONFIG_KMEMCHECK_PARTIAL_OK
>        /*
>         * Make sure _some_ bytes are initialized. Gcc frequently generates
>         * code to access neighboring bytes.
> @@ -139,13 +139,25 @@ enum kmemcheck_shadow kmemcheck_shadow_test(void *shadow, unsigned int size)
>                if (x[i] == KMEMCHECK_SHADOW_INITIALIZED)
>                        return x[i];
>        }
> +
> +       return x[0];
>  #else
> +       return kmemcheck_shadow_test_all(shadow, size);
> +#endif
> +}
> +
> +enum kmemcheck_shadow kmemcheck_shadow_test_all(void *shadow, unsigned int size)
> +{
> +       uint8_t *x;
> +       unsigned int i;
> +
> +       x = shadow;
> +
>        /* All bytes must be initialized. */
>        for (i = 0; i < size; ++i) {
>                if (x[i] != KMEMCHECK_SHADOW_INITIALIZED)
>                        return x[i];
>        }
> -#endif
>
>        return x[0];
>  }

Are we certain that size cannot be 0 in kmemcheck_shadow_test()
and kmemcheck_shadow_test_all() or other functions in
arch/x86/mm/kmemcheck/shadow.c with these unsigned
comparisons in loops?

Roel

  parent reply	other threads:[~2010-02-08 14:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08 11:16 Catalin Marinas
2010-02-08 12:54 ` Pekka Enberg
2010-02-08 12:58   ` Catalin Marinas
2010-02-08 13:03     ` Pekka Enberg
2010-02-08 14:38 ` roel kluin [this message]
2010-02-08 15:27   ` Catalin Marinas
2010-02-17 19:39 ` Pekka Enberg

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=25e057c01002080638g149c974r759f50365cd05233@mail.gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=casteyde.christian@free.fr \
    --cc=catalin.marinas@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penberg@cs.helsinki.fi \
    --cc=vegardno@ifi.uio.no \
    /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

all inboxes | Powered by JetHome®