24 Jan, 2011

1 commit


12 Jan, 2010

1 commit

  • It turns out that even zero-sized struct members (int foo[0];) will affect
    the struct layout, causing us in particular to lose 4 bytes in struct
    sock.

    This patch fixes the regression in CONFIG_KMEMCHECK=n case.

    Reported-by: Eric Dumazet
    Signed-off-by: Vegard Nossum
    Acked-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Vegard Nossum
     

23 Sep, 2009

2 commits

  • gcc permitting variable length arrays makes the current construct used for
    BUILD_BUG_ON() useless, as that doesn't produce any diagnostic if the
    controlling expression isn't really constant. Instead, this patch makes
    it so that a bit field gets used here. Consequently, those uses where the
    condition isn't really constant now also need fixing.

    Note that in the gfp.h, kmemcheck.h, and virtio_config.h cases
    MAYBE_BUILD_BUG_ON() really just serves documentation purposes - even if
    the expression is compile time constant (__builtin_constant_p() yields
    true), the array is still deemed of variable length by gcc, and hence the
    whole expression doesn't have the intended effect.

    [akpm@linux-foundation.org: make arch/sparc/include/asm/vio.h compile]
    [akpm@linux-foundation.org: more nonsensical assertions in tpm.c..]
    Signed-off-by: Jan Beulich
    Cc: Andi Kleen
    Cc: Rusty Russell
    Cc: Catalin Marinas
    Cc: "David S. Miller"
    Cc: Rajiv Andrade
    Cc: Mimi Zohar
    Cc: James Morris
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Beulich
     
  • of the form

    include/net/inet_sock.h:208: warning: ISO C90 forbids mixed declarations and code

    Cc: Johannes Berg
    Acked-by: Vegard Nossum
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     

22 Sep, 2009

2 commits


04 Sep, 2009

1 commit

  • Ingo Molnar reported the following kmemcheck warning when running both
    kmemleak and kmemcheck enabled:

    PM: Adding info for No Bus:vcsa7
    WARNING: kmemcheck: Caught 32-bit read from uninitialized memory
    (f6f6e1a4)
    d873f9f600000000c42ae4c1005c87f70000000070665f666978656400000000
    i i i i u u u u i i i i i i i i i i i i i i i i i i i i i u u u
    ^

    Pid: 3091, comm: kmemleak Not tainted (2.6.31-rc7-tip #1303) P4DC6
    EIP: 0060:[] EFLAGS: 00010006 CPU: 0
    EIP is at scan_block+0x3f/0xe0
    EAX: f40bd700 EBX: f40bd780 ECX: f16b46c0 EDX: 00000001
    ESI: f6f6e1a4 EDI: 00000000 EBP: f10f3f4c ESP: c2605fcc
    DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
    CR0: 8005003b CR2: e89a4844 CR3: 30ff1000 CR4: 000006f0
    DR0: 00000000 DR1: 00000000 DR2: 00000000 DR3: 00000000
    DR6: ffff4ff0 DR7: 00000400
    [] scan_object+0x7c/0xf0
    [] kmemleak_scan+0x1d9/0x400
    [] kmemleak_scan_thread+0x4c/0xb0
    [] kthread+0x74/0x80
    [] kernel_thread_helper+0x7/0x3c
    [] 0xffffffff
    kmemleak: 515 new suspected memory leaks (see
    /sys/kernel/debug/kmemleak)
    kmemleak: 42 new suspected memory leaks (see /sys/kernel/debug/kmemleak)

    The problem here is that kmemleak will scan partially initialized
    objects that makes kmemcheck complain. Fix that up by skipping
    uninitialized memory regions when kmemcheck is enabled.

    Reported-by: Ingo Molnar
    Acked-by: Ingo Molnar
    Acked-by: Catalin Marinas
    Signed-off-by: Pekka Enberg

    Pekka Enberg
     

15 Jun, 2009

4 commits

  • Add the bitfield API which can be used to annotate bitfields in structs
    and get rid of false positive reports.

    According to Al Viro, the syntax we were using (putting #ifdef inside
    macro arguments) was not valid C. He also suggested using begin/end
    markers instead, which is what we do now.

    [rebased for mainline inclusion]
    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • This adds support for tracking the initializedness of memory that
    was allocated with the page allocator. Highmem requests are not
    tracked.

    Cc: Dave Hansen
    Acked-by: Pekka Enberg

    [build fix for !CONFIG_KMEMCHECK]
    Signed-off-by: Ingo Molnar

    [rebased for mainline inclusion]
    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • This patch hooks into the DMA API to prevent the reporting of the
    false positives that would otherwise be reported when memory is
    accessed that is also used directly by devices.

    [rebased for mainline inclusion]
    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • With kmemcheck enabled, the slab allocator needs to do this:

    1. Tell kmemcheck to allocate the shadow memory which stores the status of
    each byte in the allocation proper, e.g. whether it is initialized or
    uninitialized.
    2. Tell kmemcheck which parts of memory that should be marked uninitialized.
    There are actually a few more states, such as "not yet allocated" and
    "recently freed".

    If a slab cache is set up using the SLAB_NOTRACK flag, it will never return
    memory that can take page faults because of kmemcheck.

    If a slab cache is NOT set up using the SLAB_NOTRACK flag, callers can still
    request memory with the __GFP_NOTRACK flag. This does not prevent the page
    faults from occuring, however, but marks the object in question as being
    initialized so that no warnings will ever be produced for this object.

    In addition to (and in contrast to) __GFP_NOTRACK, the
    __GFP_NOTRACK_FALSE_POSITIVE flag indicates that the allocation should
    not be tracked _because_ it would produce a false positive. Their values
    are identical, but need not be so in the future (for example, we could now
    enable/disable false positives with a config option).

    Parts of this patch were contributed by Pekka Enberg but merged for
    atomicity.

    Signed-off-by: Vegard Nossum
    Signed-off-by: Pekka Enberg
    Signed-off-by: Ingo Molnar

    [rebased for mainline inclusion]
    Signed-off-by: Vegard Nossum

    Vegard Nossum
     

13 Jun, 2009

1 commit

  • General description: kmemcheck is a patch to the linux kernel that
    detects use of uninitialized memory. It does this by trapping every
    read and write to memory that was allocated dynamically (e.g. using
    kmalloc()). If a memory address is read that has not previously been
    written to, a message is printed to the kernel log.

    Thanks to Andi Kleen for the set_memory_4k() solution.

    Andrew Morton suggested documenting the shadow member of struct page.

    Signed-off-by: Vegard Nossum
    Signed-off-by: Pekka Enberg

    [export kmemcheck_mark_initialized]
    [build fix for setup_max_cpus]
    Signed-off-by: Ingo Molnar

    [rebased for mainline inclusion]
    Signed-off-by: Vegard Nossum

    Vegard Nossum