kernel-ark/kernel
Andi Kleen d025c9db7f [PATCH] Support piping into commands in /proc/sys/kernel/core_pattern
Using the infrastructure created in previous patches implement support to
pipe core dumps into programs.

This is done by overloading the existing core_pattern sysctl
with a new syntax:

|program

When the first character of the pattern is a '|' the kernel will instead
threat the rest of the pattern as a command to run.  The core dump will be
written to the standard input of that program instead of to a file.

This is useful for having automatic core dump analysis without filling up
disks.  The program can do some simple analysis and save only a summary of
the core dump.

The core dump proces will run with the privileges and in the name space of
the process that caused the core dump.

I also increased the core pattern size to 128 bytes so that longer command
lines fit.

Most of the changes comes from allowing core dumps without seeks.  They are
fairly straight forward though.

One small incompatibility is that if someone had a core pattern previously
that started with '|' they will get suddenly new behaviour.  I think that's
unlikely to be a real problem though.

Additional background:

> Very nice, do you happen to have a program that can accept this kind of
> input for crash dumps?  I'm guessing that the embedded people will
> really want this functionality.

I had a cheesy demo/prototype.  Basically it wrote the dump to a file again,
ran gdb on it to get a backtrace and wrote the summary to a shared directory.
Then there was a simple CGI script to generate a "top 10" crashes HTML
listing.

Unfortunately this still had the disadvantage to needing full disk space for a
dump except for deleting it afterwards (in fact it was worse because over the
pipe holes didn't work so if you have a holey address map it would require
more space).

Fortunately gdb seems to be happy to handle /proc/pid/fd/xxx input pipes as
cores (at least it worked with zsh's =(cat core) syntax), so it would be
likely possible to do it without temporary space with a simple wrapper that
calls it in the right way.  I ran out of time before doing that though.

The demo prototype scripts weren't very good.  If there is really interest I
can dig them out (they are currently on a laptop disk on the desk with the
laptop itself being in service), but I would recommend to rewrite them for any
serious application of this and fix the disk space problem.

Also to be really useful it should probably find a way to automatically fetch
the debuginfos (I cheated and just installed them in advance).  If nobody else
does it I can probably do the rewrite myself again at some point.

My hope at some point was that desktops would support it in their builtin
crash reporters, but at least the KDE people I talked too seemed to be happy
with their user space only solution.

Alan sayeth:

  I don't believe that piping as such as neccessarily the right model, but
  the ability to intercept and processes core dumps from user space is asked
  for by many enterprise users as well.  They want to know about, capture,
  analyse and process core dumps, often centrally and in automated form.

[akpm@osdl.org: loff_t != unsigned long]
Signed-off-by: Andi Kleen <ak@suse.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-10-01 00:39:33 -07:00
..
irq
power
time [PATCH] kernel/time/ntp.c: possible cleanups 2006-10-01 00:39:27 -07:00
.gitignore
acct.c [PATCH] csa: convert CONFIG tag for extended accounting routines 2006-10-01 00:39:29 -07:00
audit.c
audit.h
auditfilter.c
auditsc.c [PATCH] audit/accounting: tty locking 2006-09-29 09:18:25 -07:00
capability.c [PATCH] pidspace: is_init() 2006-09-29 09:18:12 -07:00
compat.c [PATCH] BLOCK: Move extern declarations out of fs/*.c into header files [try #6] 2006-09-30 20:52:18 +02:00
configs.c
cpu.c
cpuset.c [PATCH] r/o bind mount prepwork: inc_nlink() helper 2006-10-01 00:39:30 -07:00
delayacct.c
dma.c
exec_domain.c
exit.c [PATCH] csa: convert CONFIG tag for extended accounting routines 2006-10-01 00:39:29 -07:00
extable.c
fork.c [PATCH] csa: convert CONFIG tag for extended accounting routines 2006-10-01 00:39:29 -07:00
futex_compat.c
futex.c [PATCH] sys_get_robust_list(): don't take tasklist_lock 2006-09-29 09:18:18 -07:00
hrtimer.c [PATCH] posix-timers: Fix clock_nanosleep() doesn't return the remaining time in compatibility mode 2006-09-29 09:18:15 -07:00
itimer.c
kallsyms.c
Kconfig.hz
Kconfig.preempt
kexec.c [PATCH] kexec warning fix 2006-09-29 09:18:15 -07:00
kfifo.c [PATCH] memory ordering in __kfifo primitives 2006-09-29 09:18:13 -07:00
kmod.c [PATCH] Support piping into commands in /proc/sys/kernel/core_pattern 2006-10-01 00:39:33 -07:00
kprobes.c
ksysfs.c
kthread.c
latency.c [PATCH] maximum latency tracking infrastructure 2006-10-01 00:39:19 -07:00
lockdep_internals.h
lockdep_proc.c
lockdep.c [PATCH] lockdep core: improve the lock-chain-hash 2006-09-29 09:18:25 -07:00
Makefile [PATCH] csa: basic accounting over taskstats 2006-10-01 00:39:29 -07:00
module.c [PATCH] /sys/modules: allow full length section names 2006-09-29 09:18:23 -07:00
mutex-debug.c
mutex-debug.h
mutex.c
mutex.h
panic.c [PATCH] x86: Clean up x86 NMI sysctls 2006-09-30 01:47:55 +02:00
params.c
pid.c
posix-cpu-timers.c [PATCH] posix-timers: Fix the flags handling in posix_cpu_nsleep() 2006-09-29 09:18:15 -07:00
posix-timers.c [PATCH] posix-timers: Fix clock_nanosleep() doesn't return the remaining time in compatibility mode 2006-09-29 09:18:15 -07:00
printk.c
profile.c
ptrace.c [PATCH] pidspace: is_init() 2006-09-29 09:18:12 -07:00
rcupdate.c
rcutorture.c
relay.c
resource.c
rtmutex_common.h
rtmutex-debug.c
rtmutex-debug.h
rtmutex-tester.c
rtmutex.c [PATCH] clean up and remove some extra spinlocks from rtmutex 2006-09-29 09:18:09 -07:00
rtmutex.h
rwsem.c
sched.c [PATCH] csa: convert CONFIG tag for extended accounting routines 2006-10-01 00:39:29 -07:00
seccomp.c
signal.c [PATCH] __dequeue_signal() cleanup 2006-09-29 09:18:15 -07:00
softirq.c [PATCH] check return value of cpu_callback 2006-09-29 09:18:14 -07:00
softlockup.c [PATCH] check return value of cpu_callback 2006-09-29 09:18:14 -07:00
spinlock.c [PATCH] Directed yield: cpu_relax variants for spinlocks and rw-locks 2006-10-01 00:39:21 -07:00
stacktrace.c
stop_machine.c [PATCH] stop_machine.c copyright 2006-09-29 09:18:24 -07:00
sys_ni.c [PATCH] BLOCK: Make it possible to disable the block layer [try #6] 2006-09-30 20:52:31 +02:00
sys.c [PATCH] CodingStyle cleanup for kernel/sys.c 2006-10-01 00:39:20 -07:00
sysctl.c [PATCH] Support piping into commands in /proc/sys/kernel/core_pattern 2006-10-01 00:39:33 -07:00
taskstats.c [PATCH] csa: Extended system accounting over taskstats 2006-10-01 00:39:29 -07:00
time.c [PATCH] NTP: Move all the NTP related code to ntp.c 2006-10-01 00:39:26 -07:00
timer.c [PATCH] kill wall_jiffies 2006-10-01 00:39:27 -07:00
tsacct.c [PATCH] csa accounting taskstats update 2006-10-01 00:39:29 -07:00
uid16.c
unwind.c [PATCH] unwind: fix unused variable warning when !CONFIG_MODULES 2006-09-29 09:18:11 -07:00
user.c
wait.c
workqueue.c