From: Mark Wielaard Date: Sun, 28 Jun 2020 13:27:25 +0000 (+0200) Subject: libdwfl: read_address should use increasing address in intuit_kernel_bounds X-Git-Tag: elfutils-0.181~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=eff30a6dabe52ac77ee5c6a0d31853fc8e3aeadb;p=thirdparty%2Felfutils.git libdwfl: read_address should use increasing address in intuit_kernel_bounds In kernels from 4.14 up to 4.19 in /proc/kallsyms there are special __entry_SYSCALL_64_trampoline symbols. The problem is that they come after the last kernel address, but before the module addresses. And they are (much) smaller than the start address we found. This confuses intuit_kernel_bounds and makes it fail. Make sure to check read_address returns an increasing address when searching for the end. https://sourceware.org/bugzilla/show_bug.cgi?id=26177 Reported-by: Vitaly Chikunov Signed-off-by: Mark Wielaard --- diff --git a/libdw/ChangeLog b/libdw/ChangeLog index 72cd50034..c11df151e 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -1,3 +1,8 @@ +2020-06-28 Mark Wielaard + + * linux-kernel-modules.c (intuit_kernel_bounds): Check read_address + returns an increasing address when searching for end. + 2020-06-16 Mark Wielaard * cfi.c (execute_cfi): Add missing FALLTHROUGH. diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 84a05f28b..548cb56f9 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -538,10 +538,14 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes) if (result == 0) { + Dwarf_Addr addr; *end = *start; - while (read_address (&state, end)) - if (*notes == 0 && !strcmp (state.p, "__start_notes\n")) - *notes = *end; + while (read_address (&state, &addr) && addr >= *end) + { + *end = addr; + if (*notes == 0 && !strcmp (state.p, "__start_notes\n")) + *notes = *end; + } Dwarf_Addr round_kernel = sysconf (_SC_PAGESIZE); *start &= -(Dwarf_Addr) round_kernel;