Fix for the "kmem [-s|-S] <address>" command, and the "rd -S[S]"

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)
This commit is contained in:
Dave Anderson 2014-12-10 15:04:40 -05:00
parent 2562642c5f
commit 8b2cb365d7

View File

@ -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)
@ -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))) {