Skip to content

Commit

Permalink
Fix for the "kmem [-s|-S] <address>" command, and the "rd -S[S]"
Browse files Browse the repository at this point in the history
and "bt -F[F]" options.  Without the patch, if the page structure
associated with a memory address still contains a (stale) pointer to
the address of a kmem_cache structure, but whose page.flags does not
have the PG_slab bit set, the address is incorrectly presumed to be
contained within that slab cache.  As as result, the "kmem" command
may display one or more messages indicating a "bad inuse counter", a
"bad next pointer" or a "bad s_mem pointer", followed by an "address
not found in cache" error message.  The "rd -S[S]" and "bt -F[F]"
commands may mislabel memory locations as belonging to slab caches.
(anderson@redhat.com)
  • Loading branch information
Dave Anderson committed Dec 10, 2014
1 parent 2562642 commit 8b2cb36
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -8700,8 +8700,7 @@ static char *
vaddr_to_kmem_cache(ulong vaddr, char *buf, int verbose)
{
physaddr_t paddr;
ulong page;
ulong cache;
ulong page, cache, page_flags;

if (!kvtop(NULL, vaddr, &paddr, 0)) {
if (verbose)
Expand All @@ -8719,6 +8718,14 @@ vaddr_to_kmem_cache(ulong vaddr, char *buf, int verbose)
return NULL;
}

if (vt->PG_slab) {
readmem(page+OFFSET(page_flags), KVADDR,
&page_flags, sizeof(ulong), "page.flags",
FAULT_ON_ERROR);
if (!(page_flags & (1 << vt->PG_slab)))
return NULL;
}

if ((vt->flags & KMALLOC_SLUB) ||
((vt->flags & KMALLOC_COMMON) &&
VALID_MEMBER(page_slab) && VALID_MEMBER(page_first_page))) {
Expand Down

0 comments on commit 8b2cb36

Please sign in to comment.