crash-utility / crash

Linux kernel crash utility
https://crash-utility.github.io
837 stars 274 forks source link

crash in live system use /dev/mem default when CONFIG_STRICT_DEVMEM is set #63

Open xuchunmei000 opened 4 years ago

xuchunmei000 commented 4 years ago

crash version: 7.2.8 kernel version: 4.19.91 with CONFIG_STRICT_DEVMEM=y when use crash in live system without any parameters, it will get error like this: crash

crash 7.2.8-2 Copyright (C) 2002-2020 Red Hat, Inc. Copyright (C) 2004, 2005, 2006, 2010 IBM Corporation Copyright (C) 1999-2006 Hewlett-Packard Co Copyright (C) 2005, 2006, 2011, 2012 Fujitsu Limited Copyright (C) 2006, 2007 VA Linux Systems Japan K.K. Copyright (C) 2005, 2011 NEC Corporation Copyright (C) 1999, 2002, 2007 Silicon Graphics, Inc. Copyright (C) 1999, 2000, 2001, 2002 Mission Critical Linux, Inc. This program is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Enter "help copying" to see the conditions. This program has absolutely no warranty. Enter "help warranty" for details.

GNU gdb (GDB) 7.6 Copyright (C) 2013 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "aarch64-unknown-linux-gnu"...

crash: read error: kernel virtual address: ffff000008988cf8 type: "kernel_config_data" WARNING: cannot access vmalloc'd module memory

  KERNEL: /usr/lib/debug/lib/modules/4.19.91/vmlinux
DUMPFILE: /proc/kcore
    CPUS: 128
    DATE: Tue Aug 25 18:49:40 2020
  UPTIME: 19:26:37

LOAD AVERAGE: 1.17, 1.08, 1.02 TASKS: 1377 NODENAME: j66e03465.sqa.eu95 RELEASE: 4.19.91 VERSION: #1 SMP Mon Aug 24 22:37:05 CST 2020 MACHINE: aarch64 (unknown Mhz) MEMORY: 1024 GB PID: 28923 COMMAND: "crash" TASK: ffffa07ecbccc100 [THREAD_INFO: ffffa07ecbccc100] CPU: 87 STATE: TASK_RUNNING (ACTIVE)

WARNING: could not find MAGIC_START!

the result of read symbol is not correct: *crash> p cpufreq_global_kobject cpufreq_global_kobject = $1 = (struct kobject ) 0x0 WARNING: could not find MAGIC_START!**

as crash man files says: If a MEMORY-IMAGE argument is not entered, the session will be invoked on the live system, which typically requires root privileges because of the device file used to access system RAM. By default, /dev/crash will be used if it exists. If it does not exist, then /dev/mem will be used; but if the kernel has been configured with CONFIG_STRICT_DEVMEM, then /proc/kcore will be used. It is permissible to explicitly enter /dev/crash, /dev/mem or /proc/kcore.

when CONFIG_STRICT_DEVMEM is set, will use /proc/kcore, but the fact is not. when use "crash /dev/mem" it will get error like "crash", when use "crash /proc/kcore", it perform ok. when use "crash -d 4", the output shows:

<readmem: ffff000008988cf8, KVADDR, "kernel_config_data", 32768, (ROE), 36e931f0> <read_dev_mem: addr: ffff000008988cf8 paddr: 988cf8 cnt: 776> /dev/mem: Operation not permitted crash: read(/dev/mem, 988cf8, 776): 4294967295 (ffffffff) crash: read error: kernel virtual address: ffff000008988cf8 type: "kernel_config_data" <readmem: ffff000009137980, KVADDR, "devmem_is_allowed - jiffies", 8, (ROE|Q|NDS), ffffe06afe00> <read_dev_mem: addr: ffff000009137980 paddr: 1137980 cnt: 8> /dev/mem: Operation not permitted crash: read(/dev/mem, 1137980, 8): 4294967295 (ffffffff) crash: read error: kernel virtual address: ffff000009137980 type: "devmem_is_allowed - jiffies" crash: this kernel may be configured with CONFIG_STRICT_DEVMEM, which renders /dev/mem unusable as a live memory source. crash: trying /proc/kcore as an alternative to /dev/mem

xuchunmei000 commented 4 years ago

crash does not use /proc/kcore default when CONFIG_STRICT_DEVMEM is set, just when read /dev/mem failed, then switch to use /proc/kcore, is it by design?

k-hagio commented 4 years ago

crash does not use /proc/kcore default when CONFIG_STRICT_DEVMEM is set, just when read /dev/mem failed, then switch to use /proc/kcore, is it by design?

Yes, it seems so. Do you mean that there is a case that switching to /proc/kcore doesn't work well?

xuchunmei000 commented 4 years ago

crash does not use /proc/kcore default when CONFIG_STRICT_DEVMEM is set, just when read /dev/mem failed, then switch to use /proc/kcore, is it by design?

Yes, it seems so. Do you mean that there is a case that switching to /proc/kcore doesn't work well?

In live system, use "crash" without any parameters, it will get error and cannot read symbol. when use "crash /proc/kcore", it performs ok, no error message and can read symbol successfully.