20
kexec, kdump, and crash Presented by: Ben Buzbee Pika-Tux

k exec , kdump , and crash Presented by: Ben Buzbee

  • Upload
    phil

  • View
    18

  • Download
    0

Embed Size (px)

DESCRIPTION

k exec , kdump , and crash Presented by: Ben Buzbee. Pika -Tux. Overview. Overview of System Kexec Kernel compilation parameters Kdump Analysis. Kdump Overview. We compile two kernels of the same version We run the first kernel (production kernel) until it crashes - PowerPoint PPT Presentation

Citation preview

Page 1: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

kexec, kdump, and crashPresented by: Ben Buzbee

Pika-Tux

Page 2: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Overview

• Overview of System• Kexec• Kernel compilation parameters• Kdump• Analysis

Page 3: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Kdump Overview

• We compile two kernels of the same version• We run the first kernel (production kernel)

until it crashes• When it crashes, the kdump service uses kexec

to load our section kernel (crash kernel) which dumps the crash parameters of the first

Page 4: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Production Kernel

Crash Kernel

Kdump ServiceDisk

Main Memory

Load

s

kexec

reads

writes

Page 5: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Crash tool

• Crash analyzes kernel memory– Requires the context of vmlinux

• Can analyze a crashed kernel’s memory dump• Can analyze a running kernel’s memory

Page 6: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Kexec

• Packaged with kdump• Used to execute a Linux kernel directly• Serves the function of a bootloader• apt-get install kdump-tools– Installs all the tools we need

Page 7: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Kernel Compilation Parameters

• CONFIG_KEXEC=y– Allows kexec to run the kernel directly

• CONFIG_CRASH_DUMP=y– Enables crash dumps so that kdump can work

• CONFIG_SMP=n– Required if you have multiple processors, kdump

only works with one. (Symmetric Multi-Processing)

Page 8: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Parameters Continued

• CONFIG_DEBUG_INFO=y– Builds with symbols

• CONFIG_PHYSICAL_START=0x1000000– Where the production kernel starts, must leave

enough room for crash kernel before it

Page 9: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Crash Kernel

• Configure the same way as above, except must not use compression

• Since it’s uncompressed, will be vmlinux• Append –kdump

Page 10: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Configure Kdump

• /etc/sysconfig/kdump• KDUMP_RUNLEVEL=1– Runlevel for the crash kernel

• KDUMP_SAVEDIR=file:///var/log/dump– Where to save dump

Page 11: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Edit the Boot Loader

• Edit grub to reserve some memory for the crash kernel– crashkernel=XM@YM• X is the offset, Y is the size (In MB)

• This is probably where I made a mistake– New grub menu? I did something wrong? Can’t

tell.

Page 12: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Problems…

• So that didn’t work…• Next approach: can I get crash to work on live

memory?

Page 13: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Crash Utility

• Analyzes kernel memory – Primarily, to determine the cause of a crash

• Best use:– Analyze memory dumped after a crash (kdump)

• Resigned use:– Analyze running memory from /dev/mem

Page 14: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Curse you kexec…

• Tried to execute manually• Now every time I reboot, it tries to do this and

fails– Wrote a value somewhere that it doesn’t clean

up?

Page 15: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Crash

• CONFIG_STRICT_DEVMEM=n– Otherwise we can’t view kernel memory while its

running• Syntax: crash vmlinux System.map– Must be uncompressed (i.e. not vmlinuz)– Made me use the System.map even though the

versions were the same – not sure why

Page 16: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Crash - Problem

• Read error: kernel virtual address: c124edb8 type: ‘cpu_possible_mask’

• Solution: Unknown• Workaround: --minimal– Not ideal: Only allows a small subset of the total

command set

Page 17: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

(Minimal) Commands

• Log– Dump message buffer– Usefulness: High on crashed kernels, low

otherwise• sym <symbol>– Translates symbol to virtual address– Usefulness: Low-Moderate (with rd)

Page 18: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

(Minimal) Commands

• rd– Read memory– Usefulness: Moderate

• dis– Disassembles code at a given address– Usefulness: Low

Page 19: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

(Minimal) Commands

• eval– Evaluates an expression– Usefulness: Low (I have a calculator)

Page 20: k exec ,  kdump ,  and crash Presented by: Ben  Buzbee

Conclusion

• The setup is very involved and detailed• I failed at it miserably• The live analysis using crash is not particularly

helpful• The dump analysis using crash is moderately

helpful– Maybe not worth the trouble of setup?