I found this particular issue while compiling and installing
a kernel from source on a RHEL arm64 machine. I used the following
commands to build and install the kernel from source:
# make olddefconfig
# make
# make modules_install INSTALL_MOD_STRIP=1 && make install
This compiles and installs both 'vmlinux' and 'vmlinux.o' at
the following standard location - '/lib/modules/<kernel>/build/
Now the problem can be reproduced using the following steps:
1. Update grub to boot the freshly compiled kernel.
2. Reboot machine.
3. Now, run crash on live system, it errors out with the following
messages:
crash: invalid kernel virtual address: 8470 type: "possible"
WARNING: cannot read cpu_possible_map
crash: invalid kernel virtual address: 8270 type: "present"
WARNING: cannot read cpu_present_map
crash: invalid kernel virtual address: 8070 type: "online"
WARNING: cannot read cpu_online_map
crash: invalid kernel virtual address: 8670 type: "active"
WARNING: cannot read cpu_active_map
crash: cannot resolve "_stext"
4. Enabling some debug messages in 'find_booted_kernel()' function
tells us that it finds 'vmlinux.o' earlier than 'vmlinux' and accepts
that as the kernel being boot'ed:
find_booted_kernel: check: /lib/modules/4.14.0/build/vmlinux.o
find_booted_kernel: found: /lib/modules/4.14.0/build/vmlinux.o
5. Now the problem happens due to following check inside
'find_booted_kernel()' function:
if (mount_point(kernel) ||
!file_readable(kernel) ||
!is_elf_file(kernel))
continue;
6. Since 'vmlinux.o' is a elf file, is readable and is not
mount'able, so the check in point 5 fails and we incorrectly
accept this as the kernel being boot'ed, even though
there was a 'vmlinux' present inside
'/lib/modules/<kernel>/build'.
7. Now, later when crash tries to access symbols (like _stext)
using this kernel symbol file, we see errors.
Fix this by skipping 'vmlinux.o' from the check in point 5,
so that we can select 'vmlinux' correctly as the kernel file.
After this fix, crash no longer errors out and we can use
full functionality on the crash prompt.
Signed-off-by: Bhupesh Sharma <bhsharma(a)redhat.com>
---
filesys.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/filesys.c b/filesys.c
index 1b44ad5cefa8..9f240d6115a1 100644
--- a/filesys.c
+++ b/filesys.c
@@ -623,9 +623,21 @@ find_booted_kernel(void)
sprintf(kernel, "%s%s", searchdirs[i], dp->d_name);
+ /* We may run into a special case with
+ * 'vmlinux.o' been present inside
+ * '/lib/modules/<kernel>/build/',
+ * which has some special characteristics -
+ * this is a elf file, is readable and is not
+ * mount'able.
+ *
+ * So we need to handle this properly here to
+ * make sure that we get to the real 'vmlinux'
+ * rather than the 'vmlinux.o'
+ */
if (mount_point(kernel) ||
!file_readable(kernel) ||
- !is_elf_file(kernel))
+ !is_elf_file(kernel) ||
+ !(strcmp(dp->d_name, "vmlinux.o")))
continue;
if (CRASHDEBUG(1))
--
2.7.4