From dbc34b89061feae88e0641eab4c82e48903b8396 Mon Sep 17 00:00:00 2001 From: Kingwel Xie Date: Sun, 11 Nov 2018 22:55:58 -0500 Subject: pmalloc: correct format_pmalloc_map u32 index overrun bug Change-Id: I95ba4eab6e2154ef33a479450b997c8317db3a92 Signed-off-by: Kingwel Xie --- src/vppinfra/pmalloc.c | 7 +++---- src/vppinfra/pmalloc.h | 1 - 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'src/vppinfra') diff --git a/src/vppinfra/pmalloc.c b/src/vppinfra/pmalloc.c index b707336bfbd..e903511ab81 100644 --- a/src/vppinfra/pmalloc.c +++ b/src/vppinfra/pmalloc.c @@ -359,7 +359,6 @@ pmalloc_map_pages (clib_pmalloc_main_t * pm, clib_pmalloc_arena_t * a, pp->n_free_blocks = 1 << (pm->def_log2_page_sz - PMALLOC_LOG2_BLOCK_SZ); pp->index = pp - pm->pages; pp->arena_index = a->index; - pp->pa = (uword) va + (1 << pm->def_log2_page_sz) * i; vec_add1 (a->page_indices, pp->index); a->n_pages++; } @@ -608,8 +607,6 @@ format_pmalloc_page (u8 * s, va_list * va) int verbose = va_arg (*va, int); u32 indent = format_get_indent (s); - s = format (s, "page %u: phys-addr %p ", pp->index, pp->pa); - if (pp->chunks == 0) return s; @@ -699,7 +696,9 @@ format_pmalloc_map (u8 * s, va_list * va) { uword *lookup_val, pa, va; lookup_val = vec_elt_at_index (pm->lookup_table, index); - va = pointer_to_uword (pm->base) + (index << pm->lookup_log2_page_sz); + va = + pointer_to_uword (pm->base) + + ((uword) index << pm->lookup_log2_page_sz); pa = va - *lookup_val; s = format (s, "\n %16p %13p %8U", uword_to_pointer (va, u64), diff --git a/src/vppinfra/pmalloc.h b/src/vppinfra/pmalloc.h index eae317fb945..25c46783f8c 100644 --- a/src/vppinfra/pmalloc.h +++ b/src/vppinfra/pmalloc.h @@ -36,7 +36,6 @@ typedef struct { u32 index; u32 arena_index; - uword pa; clib_pmalloc_chunk_t *chunks; u32 first_chunk_index; u32 n_free_chunks; -- cgit 1.2.3-korg