15 Jun, 2009

24 commits

  • kmemcheck reports a use of uninitialized memory here, but it's not
    a real error. The structure in question has just been allocated, and
    the whole field is initialized, but it happens in two steps.

    We fix the false positive by inserting a kmemcheck annotation.

    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • 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
     
  • We've had some troubles in the past with weird instructions. This
    patch adds a self-test framework which can be used to verify that
    a certain set of opcodes are decoded correctly. Of course, the
    opcodes which are not tested can still give the wrong results.

    In short, this is just a safeguard to catch unintentional changes
    in the opcode decoder. It does not mean that errors can't still
    occur!

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

    Vegard Nossum
     
  • Unify and demacro pte_hidden.

    Signed-off-by: Jeremy Fitzhardinge

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

    Jeremy Fitzhardinge
     
  • Only _PAGE_HIDDEN when CONFIG_KMEMCHECK is defined, otherwise set it
    to 0. Allows later cleanups.

    Signed-off-by: Jeremy Fitzhardinge

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

    Jeremy Fitzhardinge
     
  • The Kconfig options of kmemcheck are hidden under arch/x86 which makes porting
    to other architectures harder. To fix that, move the Kconfig bits to
    lib/Kconfig.kmemcheck and introduce a CONFIG_HAVE_ARCH_KMEMCHECK config option
    that architectures can define.

    Signed-off-by: Pekka Enberg

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

    Pekka Enberg
     
  • let it rip!

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

    [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 is needed for page allocator support to prevent false positives
    when accessing pages which are dma-mapped.

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

    Vegard Nossum
     
  • As these are allocated using the page allocator, we need to pass
    __GFP_NOTRACK before we add page allocator support to kmemcheck.

    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • The xor tests are run on uninitialized data, because it is doesn't
    really matter what the underlying data is. Annotate this false-
    positive warning.

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

    Vegard Nossum
     
  • We now have SLAB support for kmemcheck! This means that it doesn't matter
    whether one chooses SLAB or SLUB, or indeed whether Linus chooses to chuck
    SLAB or SLUB.. ;-)

    Cc: Ingo Molnar
    Cc: Christoph Lameter
    Cc: Andrew Morton
    Signed-off-by: Pekka Enberg

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

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

    Cc: Christoph Lameter
    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
     
  • 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
     
  • The hooks that we modify are:
    - Page fault handler (to handle kmemcheck faults)
    - Debug exception handler (to hide pages after single-stepping
    the instruction that caused the page fault)

    Also redefine memset() to use the optimized version if kmemcheck is
    enabled.

    (Thanks to Pekka Enberg for minimizing the impact on the page fault
    handler.)

    As kmemcheck doesn't handle MMX/SSE instructions (yet), we also disable
    the optimized xor code, and rely instead on the generic C implementation
    in order to avoid false-positive warnings.

    Signed-off-by: Vegard Nossum

    [whitespace fixlet]
    Signed-off-by: Pekka Enberg
    Signed-off-by: Ingo Molnar

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

    Vegard Nossum
     
  • Lets use kmemcheck_pte_lookup() in kmemcheck_fault() instead of
    open-coding it there.

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

    Pekka Enberg
     
  • This patch moves the CONFIG_X86_64 ifdef out of kmemcheck_opcode_decode() by
    introducing a version of the function that always returns false for
    CONFIG_X86_32.

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

    Pekka Enberg
     
  • Multiple ifdef'd definitions of the same global variable is ugly and
    error-prone. Fix that up.

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

    Pekka Enberg
     
  • The "Bugs, beware!" printout during is cute but confuses users that something
    bad happened so change the text to the more boring "Initialized" message.

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

    Pekka Enberg
     
  • This patch reorders code in error.c so that we can get rid of the forward
    declarations.

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

    Pekka Enberg
     

13 Jun, 2009

8 commits

  • kmemcheck/shadow.c needs to include to prevent
    the following warnings:

    linux-next-20080724/arch/x86/mm/kmemcheck/shadow.c:64: warning : data definition has no type or storage class
    linux-next-20080724/arch/x86/mm/kmemcheck/shadow.c:64: warning : type defaults to 'int' in declaration of 'EXPORT_SYMBOL_GPL'
    linux-next-20080724/arch/x86/mm/kmemcheck/shadow.c:64: warning : parameter names (without types) in function declaration

    Signed-off-by: Randy Dunlap
    Cc: vegardno@ifi.uio.no
    Cc: penberg@cs.helsinki.fi
    Cc: akpm
    Signed-off-by: Ingo Molnar

    Randy Dunlap
     
  • 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
     
  • Thanks to Sitsofe Wheeler, Randy Dunlap, and Jonathan Corbet for providing
    input and feedback on this!

    Signed-off-by: Vegard Nossum

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

    Pekka Enberg
     
  • Rationale: kmemcheck needs to be able to schedule a tasklet without
    touching any dynamically allocated memory _at_ _all_ (since that would
    lead to a recursive page fault). This tasklet is used for writing the
    error reports to the kernel log.

    The new scheduling function avoids touching any other tasklets by
    inserting the new tasklist as the head of the "tasklet_hi" list instead
    of on the tail.

    Also don't wake up the softirq thread lest the scheduler access some
    tracked memory and we go down with a recursive page fault.

    In this case, we'd better just wait for the maximum time of 1/HZ for the
    message to appear.

    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • Move the SLAB struct kmem_cache definition to like
    with SLUB so kmemcheck can access ->ctor and ->flags.

    Cc: Ingo Molnar
    Cc: Christoph Lameter
    Cc: Andrew Morton
    Signed-off-by: Pekka Enberg

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

    Pekka Enberg
     
  • This is needed if the header is to be free-standing.

    Signed-off-by: Vegard Nossum

    Vegard Nossum
     
  • This will help kmemcheck (and possibly other debugging tools) since we
    can now simply pass regs->bp to the stack tracer instead of specifying
    the number of stack frames to skip, which is unreliable if gcc decides
    to inline functions, etc.

    Note that this makes the API incomplete for other architectures, but I
    expect that those can be updated lazily, e.g. when they need it.

    Cc: Arjan van de Ven
    Signed-off-by: Vegard Nossum

    Vegard Nossum
     

12 Jun, 2009

8 commits

  • Fix kernel-doc warnings in recently changed block/ source code.

    Signed-off-by: Randy Dunlap
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs-2.6: (87 commits)
    nilfs2: get rid of bd_mount_sem use from nilfs
    nilfs2: correct exclusion control in nilfs_remount function
    nilfs2: simplify remaining sget() use
    nilfs2: get rid of sget use for checking if current mount is present
    nilfs2: get rid of sget use for acquiring nilfs object
    nilfs2: remove meaningless EBUSY case from nilfs_get_sb function
    remove the call to ->write_super in __sync_filesystem
    nilfs2: call nilfs2_write_super from nilfs2_sync_fs
    jffs2: call jffs2_write_super from jffs2_sync_fs
    ufs: add ->sync_fs
    sysv: add ->sync_fs
    hfsplus: add ->sync_fs
    hfs: add ->sync_fs
    fat: add ->sync_fs
    ext2: add ->sync_fs
    exofs: add ->sync_fs
    bfs: add ->sync_fs
    affs: add ->sync_fs
    sanitize ->fsync() for affs
    repair bfs_write_inode(), switch bfs to simple_fsync()
    ...

    Linus Torvalds
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gerg/m68knommu:
    m68knommu: remove unecessary include of thread_info.h in entry.S
    m68knommu: enumerate INIT_THREAD fields properly
    headers_check fix: m68k, swab.h
    arch/m68knommu: Convert #ifdef DEBUG printk(KERN_DEBUG to pr_debug(
    m68knommu: remove obsolete reset code
    m68knommu: move CPU reset code for the 5272 ColdFire into its platform code
    m68knommu: move CPU reset code for the 528x ColdFire into its platform code
    m68knommu: move CPU reset code for the 527x ColdFire into its platform code
    m68knommu: move CPU reset code for the 523x ColdFire into its platform code
    m68knommu: move CPU reset code for the 520x ColdFire into its platform code
    m68knommu: add CPU reset code for the 532x ColdFire
    m68knommu: add CPU reset code for the 5249 ColdFire
    m68knommu: add CPU reset code for the 5206e ColdFire
    m68knommu: add CPU reset code for the 5206 ColdFire
    m68knommu: add CPU reset code for the 5407 ColdFire
    m68knommu: add CPU reset code for the 5307 ColdFire
    m68knommu: merge system reset for code ColdFire 523x family
    m68knommu: fix system reset for ColdFire 527x family

    Linus Torvalds
     
  • zalloc_cpumask_var already cleared it.

    Signed-off-by: Yinghai Lu
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     
  • So we make sure MAXSMP gets a cleared cpumask

    Signed-off-by: Yinghai Lu
    Signed-off-by: Linus Torvalds

    Yinghai Lu
     
  • Commit 925d519ab82b6dd7aca9420d809ee83819c08db2 ("perf_counter:
    unify and fix delayed counter wakeup") added global definitions.

    Signed-off-by: Stephen Rothwell
    Acked-by: Paul Mackerras
    Acked-by: Benjamin Herrenschmidt
    Signed-off-by: Linus Torvalds

    Stephen Rothwell
     
  • This will remove every bd_mount_sem use in nilfs.

    The intended exclusion control was replaced by the previous patch
    ("nilfs2: correct exclusion control in nilfs_remount function") for
    nilfs_remount(), and this patch will replace remains with a new mutex
    that this inserts in nilfs object.

    Signed-off-by: Ryusuke Konishi
    Cc: Christoph Hellwig
    Signed-off-by: Al Viro

    Ryusuke Konishi
     
  • nilfs_remount() changes mount state of a superblock instance. Even
    though nilfs accesses other superblock instances during mount or
    remount, the mount state was not properly protected in
    nilfs_remount().

    Moreover, nilfs_remount() has a lock order reversal problem;
    nilfs_get_sb() holds:

    1. bdev->bd_mount_sem
    2. sb->s_umount (sget acquires)

    and nilfs_remount() holds:

    1. sb->s_umount (locked by the caller in vfs)
    2. bdev->bd_mount_sem

    To avoid these problems, this patch divides a semaphore protecting
    super block instances from nilfs->ns_sem, and applies it to the mount
    state protection in nilfs_remount().

    With this change, bd_mount_sem use is removed from nilfs_remount() and
    the lock order reversal will be resolved. And the new rw-semaphore,
    nilfs->ns_super_sem will properly protect the mount state except the
    modification from nilfs_error function.

    Signed-off-by: Ryusuke Konishi
    Signed-off-by: Al Viro

    Ryusuke Konishi