From e81db08bc69fb1a7a7e48f892c2038d992a71f6d Mon Sep 17 00:00:00 2001 From: Dave Anderson Date: Fri, 27 Oct 2017 14:10:43 -0400 Subject: [PATCH] Fix for the validation of the bits located in the least signficant bits of mem_section.section_mem_map pointers. Without the patch, the validation functions always returned valid, due to a coding error found by clang. However, it was never really a problem because it is extremely unlikely that an existing mem_section would ever be invalid. (oleksandr@redhat.com, anderson@redhat.com) --- memory.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/memory.c b/memory.c index 9926199e..60594a4a 100644 --- a/memory.c +++ b/memory.c @@ -17003,8 +17003,8 @@ valid_section(ulong addr) if ((mem_section = read_mem_section(addr))) return (ULONG(mem_section + - OFFSET(mem_section_section_mem_map)) && - SECTION_MARKED_PRESENT); + OFFSET(mem_section_section_mem_map)) + & SECTION_MARKED_PRESENT); return 0; } @@ -17012,11 +17012,17 @@ int section_has_mem_map(ulong addr) { char *mem_section; + ulong kernel_version_bit; + + if (THIS_KERNEL_VERSION >= LINUX(2,6,24)) + kernel_version_bit = SECTION_HAS_MEM_MAP; + else + kernel_version_bit = SECTION_MARKED_PRESENT; if ((mem_section = read_mem_section(addr))) return (ULONG(mem_section + OFFSET(mem_section_section_mem_map)) - && SECTION_HAS_MEM_MAP); + & kernel_version_bit); return 0; }