Skip to contentSkip to conversation

emit logging when a process receives a fatal signal

PATCH Mikael Pettersson 3 participants 3 messages Nov 18, 2006

lore
Share & tools
lore
#0 lore raw
Quoted 14 lines · Folkert van Heusden

I found that sometimes processes disappear on some heavily used system of mine without any logging. So I've written a patch against 2.6.18.2 which emits logging when a process emits a fatal signal.

kernel/signal.c +2 -0
@@ -706,6 +706,15 @@
 	struct sigqueue * q = NULL;
 	int ret = 0;
 
+	if (sig == SIGQUIT || sig == SIGILL  || sig == SIGTRAP ||
+	    sig == SIGABRT || sig == SIGBUS  || sig == SIGFPE  ||

kernel/signal.c line 720

Quoted 10 lines
kernel/signal.c +7 -0
+	    sig == SIGSEGV || sig == SIGXCPU || sig == SIGXFSZ ||
+	    sig == SIGSYS  || sig == SIGSTKFLT)
+	{
+		printk(KERN_WARNING "Sig %d send to %d owned by %d.%d (%s)\n",
+			sig, t -> pid, t -> uid, t -> gid, t -> comm);
+	}
+
 	/*
 	 * fast-pathed signals for kernel-internal things like SIGSTOP
 	 * or SIGKILL.

NAK.

1. It lets any user DOS the system.
2. Your definition of "fatal" signals is wrong. Several of these signals can be caught, and user-space sometimes does that for good reason. FPE and SEGV are definitely often caught, BUS and ILL may be caught, and I suspect TRAP to be common in debugging sessions.
3. It puts policy in the kernel. Policy decisions belong in user-space. In this case, the policy decision is whether this type of logging is desired for a given process or not.
4. If this is about detecting the loss of specific processes (network services say), then the problem can be solved in user-space by using a separate monitor process, or by controlling the processes via ptrace.

At a minimum, the logging needs to be conditionalised on a per-process setting, and it should also be delayed until the point where a signal causes a process to be killed.

/Mikael

#1 lore raw
Quoted 4 lines

4. If this is about detecting the loss of specific processes (network services say), then the problem can be solved in user-space by using a separate monitor process, or by controlling the processes via ptrace.

No not only for specific processes. It helps you detect problems with processes you dind't know they have bugs and flakey hardware (sig 11).

Folkert van Heusden

Signature · 4 lines
Ever wonder what is out there? Any alien races? Then please support
the seti@home project: setiathome.ssl.berkeley.edu
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com
#2 lore raw
Quoted 8 lines
Quoted 5 lines

4. If this is about detecting the loss of specific processes (network services say), then the problem can be solved in user-space by using a separate monitor process, or by controlling the processes via ptrace.

No not only for specific processes. It helps you detect problems with processes you dind't know they have bugs and flakey hardware (sig 11).

Write an LSM module that hooks ->task_kill. It's probably the most beautiful and non-intrusive solution in the set of possible solutions.

	-`J'