Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 157417
b: refs/heads/master
c: 8e01936
h: refs/heads/master
i:
  157415: 8bc9db7
v: v3
  • Loading branch information
Pekka Enberg authored and Catalin Marinas committed Sep 4, 2009
1 parent 34ab826 commit e22541b
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: acde31dc467797ccae3a55b791a77af446cce018
refs/heads/master: 8e019366ba749a536131cde1947af6dcaccf8e8f
14 changes: 14 additions & 0 deletions trunk/arch/x86/mm/kmemcheck/kmemcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,20 @@ static void kmemcheck_read_strict(struct pt_regs *regs,
kmemcheck_shadow_set(shadow, size);
}

bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size)
{
enum kmemcheck_shadow status;
void *shadow;

shadow = kmemcheck_shadow_lookup(addr);
if (!shadow)
return true;

status = kmemcheck_shadow_test(shadow, size);

return status == KMEMCHECK_SHADOW_INITIALIZED;
}

/* Access may cross page boundary */
static void kmemcheck_read(struct pt_regs *regs,
unsigned long addr, unsigned int size)
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/kmemcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ void kmemcheck_mark_initialized_pages(struct page *p, unsigned int n);
int kmemcheck_show_addr(unsigned long address);
int kmemcheck_hide_addr(unsigned long address);

bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size);

#else
#define kmemcheck_enabled 0

Expand Down Expand Up @@ -99,6 +101,11 @@ static inline void kmemcheck_mark_initialized_pages(struct page *p,
{
}

static inline bool kmemcheck_is_obj_initialized(unsigned long addr, size_t size)
{
return true;
}

#endif /* CONFIG_KMEMCHECK */

/*
Expand Down
12 changes: 10 additions & 2 deletions trunk/mm/kmemleak.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
#include <asm/processor.h>
#include <asm/atomic.h>

#include <linux/kmemcheck.h>
#include <linux/kmemleak.h>

/*
Expand Down Expand Up @@ -967,15 +968,22 @@ static void scan_block(void *_start, void *_end,
unsigned long *end = _end - (BYTES_PER_POINTER - 1);

for (ptr = start; ptr < end; ptr++) {
unsigned long flags;
unsigned long pointer = *ptr;
struct kmemleak_object *object;
unsigned long flags;
unsigned long pointer;

if (allow_resched)
cond_resched();
if (scan_should_stop())
break;

/* don't scan uninitialized memory */
if (!kmemcheck_is_obj_initialized((unsigned long)ptr,
BYTES_PER_POINTER))
continue;

pointer = *ptr;

object = find_and_get_object(pointer, 1);
if (!object)
continue;
Expand Down

0 comments on commit e22541b

Please sign in to comment.