[RFC] Trapping/tracing kernel stack overflows

Martijn van Oosterhout (v3100411@student.anu.edu.au)
Fri, 09 Apr 1999 15:47:08 +1000


I have been reading linux-kernel for a while
now and have seen references to bad things
happening when the kernel stack overflows
and I have been wondering if it would be
possible to use the i386 debug registers
to trap it.

Are there any major problems with this?

Obviously you'd have to block the ptrace
GET/SETREGS. (Does anything actually use
these?) But where do these registers
get loaded into the CPU? There is nothing
in the arch/i386 directory that does it.

Another thing was what to do then. If you
want to do a printk you'd probably have to
switch stacks, meaning you'd have to allocate
one somewhere.

Any process that is that deep probably has a
lot of locks. Just dying would probably kill
everything anyway. AFAIK the linux kernel has no
machanism for undoing locks held by a faulting
process. If it did you'd be able to use the
floppy drive after the fat module had segfaulted
on a bad floppy.

Are there any other issues that would need to be
thought about?

Martijn van Oosterhout
Australia

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/