Commit Graph

13 Commits

Author SHA1 Message Date
Mathias Krause
f42db6a33f Support core files with "unusual" layout
The netdump code not only gets used for netdump/diskdump files, but also
for kdump core files. These can also be generated with the 'vmss2core'
tool that'll produce a slightly different format that isn't as densely
packed as we expect it to be. In fact, the implicit assumption that the
ELF program headers directly follow the ELF header isn't always true for
these files, as they may contain the section headers in-between -- which
is totally conforming in regards to the ELF spec. This "padding" in
combination with the implicit assumption of densely packed headers make
us interpret the section headers as program headers which is obviously
wrong.

Support these kind of core files too by not blindly assuming the program
headers follow the ELF header directly but by looking at the program
header offset in the ELF header and use that instead. Add some guarding
sanity checks to decline operating on obviously malicious or broken core
files.

To not needlessly make things too complicated, allow a "padding space"
of up to 128 bytes only.

Signed-off-by: Mathias Krause <minipli@grsecurity.net>
2020-08-12 14:18:47 +09:00
Dave Anderson
c0bbd8fae4 Add support for extended numbering support in ELF dumpfiles to handle
more than PN_XNUM (0xffff) program headers.  If the real number of
program header table entries is equal to or greater than PN_XNUM, the
e_phnum field of the ELF header is set to PN_XNUM, and the actual
number is set in the sh_info field of the section header at index 0.
(k-hagio@ab.jp.nec.com)
2019-11-08 14:00:56 -05:00
Dave Anderson
71a4f36767 Linux 4.18 kernels introduced a new CONFIG_PROC_VMCORE_DEVICE_DUMP
configuration in commit 2724273e8fd00b512596a77ee063f49b25f36507,
titled "vmcore: add API to collect hardware dump in second kernel",
in which device drivers may collect a device specific snapshot of the
hardware/firmware state of their underlying devices, and export the
data as a kdump ELF note with type NT_VMCOREDD.  This patch
recognizes the new ELF note(s) in both ELF and compressed kdump
vmcore dumpfiles.  The "help -[nD]" option shows basic information
about each note, and two new "dev" command options have been
introduced.  The "dev -V" option displays an indexed list of each
note, showing the device name, the dumpfile offset, and the size
of each note.  The "dev -v index [file]" option either dumps the
contents of a note to the display screen in a human-readable format,
or copies the note data directly to a specified file.
(surendra@chelsio.com)
2019-04-23 14:36:56 -04:00
Dave Anderson
4130b83c37 Extension of the "snap.so" extension module to pass a second
architecture-specific value in the ELF header; its initial use
is for support of the upcoming ARM64 52-bit kernel virtual
address space by passing both the VA_BITS and VA_BITS_ACTUAL
values.
(anderson@redhat.com)
2019-04-04 14:43:17 -04:00
Dave Anderson
60a42d7092 Second phase of support for the VMCOREINFO PT_NOTE added to the ELF
header of /proc/kcore in Linux 4.19 and later kernels.  This patch
introduces support for live session /proc/kcore VMCOREINFO access by
the crash utility's internal pc->read_vmcoreinfo() function.  New
usage include the initialization of the x86_64 phys_base value, and
the arm64 phys_offset, page size, and VA bits count.
(anderson@redhat.com)
2018-10-31 11:29:39 -04:00
Dave Anderson
4a8e523cd3 Account for the /proc/kcore VMCOREINFO PT_NOTE in Linux 4.19 and
later kernels having commit 23c85094fe1895caefdd19ef624ee687ec5f4507,
titled "proc/kcore: add vmcoreinfo note to /proc/kcore".  The PT_NOTE
information is stored during session initialization for later display
by "help -[n|D]"; a subsequent commit will make it available for use
by the crash utility's internal pc->read_vmcoreinfo() function.
(anderson@redhat.com)
2018-10-25 16:29:00 -04:00
Dave Anderson
5d172b230c Commit 45b74b8953 added support for
calculating phys_base and the mapped kernel offset for KASLR-enabled
kernels on SADUMP dumpfiles by using a technique developed by Takao
Indoh. Originally, the patchset included support for kdumps, but this
was dropped in v2, as it was deemed unnecessary due to the upstream
implementation of the "vmcoreinfo device" in QEMU.  However, there
are still several reasons for which the vmcoreinfo device may not be
present at the time when a memory dump is taken from a VM, ranging
from a host running older QEMU/libvirt versions, to misconfigured VMs
or environments running Hypervisors that doesn't support this device.
This patchset generalizes the KASLR-related functions from sadump.c
and moves them to kaslr_helper.c, and makes kdump analysis fall back
to KASLR offset calculation if vmcoreinfo data is missing.
(slp@redhat.com)
2018-03-29 10:26:29 -04:00
Dave Anderson
6777fe6126 Fix for the "snap.so" extension module to pass the value of the ARM64
"kimage_voffset" value in the ELF header.  Without the patch, it is
necessary to use the "--machdep kvimage_offset=<value>" command line
option, or the session fails with the message "crash: vmlinux and
vmcore do not match!".
(anderson@redhat.com)
2017-09-28 16:39:15 -04:00
Dave Anderson
8717902685 Fix for the "snap.so" extension module to pass the KASLR relocation
offset value in the dumpfile header for kernels that are compiled
with CONFIG_RANDOMIZE_BASE.  Without the patch, it is necessary to
use the "--kaslr=<offset>" command line option, or the session
fails with the message "WARNING: cannot read linux_banner string",
followed by "crash: vmlinux and vmcore do not match!".
(anderson@redhat.com)
2017-05-01 15:14:36 -04:00
Dave Anderson
9531d0f551 For many years, Xen Dom0 dumps could only be saved in ELF format.
Since makedumpfile commit 349a0ed1, it is now possible to save Xen
dumps in compressed kdump format.  This patch set adds support for
these files.  Two new files, xen_dom0.c and xen_dom0.h, have been
added to provide the common functionality required by both ELF and
compressed kdump formats.
(ptesarik@suse.cz)
2015-09-25 09:14:57 -04:00
Dave Anderson
e30594ebea Implemented a new "bt -A" option for the S390X architecture, which
adds support for displaying the new s390x vector registers.  For
ELF dumps, the registers are taken from the VX ELF notes; for s390
dumps. the registers are taken from memory.  The option produces the
same output as the -a option, but also displays the vector registers
for all active tasks.
(holzheu@linux.vnet.ibm.com)
2014-12-17 16:35:28 -05:00
Dave Anderson
045c00ac34 Added recognition of the new DUMP_DH_COMPRESSED_INCOMPLETE flag in
the header of compressed kdumps, and the new DUMP_ELF_INCOMPLETE flag
in the header of ELF kdumps.  If the makedumpfile(8) facility fails
to complete the creation of compressed or ELF kdump vmcore files
due to ENOSPC or other error, it will mark the vmcore as incomplete.
If either flag is set, the crash utility will issue a warning that
the dumpfile is known to be incomplete during initialization, just
prior to the system banner display.  When reads are attempted on
missing data, a read error will be returned.  As an alternative,
zero-filled data will be returned if the "--zero_excluded" command
line flag is used, or the "zero_excluded" runtime variable is set
to "on".  In either case, the read errors or zero-filled memory
may cause the crash session to fail entirely, cause commands to
fail, or may result in other unpredictable runtime behavior.
(anderson@redhat.com, zhouwj-fnst@cn.fujitsu.com)
2014-10-30 10:42:38 -04:00
Dave Anderson
03e3937ec7 Initial commit: crash-7.0.4 2014-01-28 16:46:11 -05:00