Re: Kernel Stack Overflows

Eric Youngdale (eric@aib.com)
Mon, 19 Feb 1996 11:01:04 -0500


>I'm becoming quite concerned about this whole issue of kernel stack
>overflows. Is there any specification for how much stack space an interrupt
>handler is allowed to use?

Yes. As little as possible :-).

In the early days of SCSI, we had problems where if you used certain
removable disks with the seagate driver, that the system would spontaneously
reboot. This was finally tracked down to a problem whereby the device
wouldn't disconnect, and as a result the seagate driver was just recursively
eating up more and more stack as long as there were more requests to
be processed. If the request queue ever became empty, all of the stack
would be released, of course. As I recall, we were able to recurse
something
like 15 to 20 times before the stack overflowed (or was it before the
system crashed?).

One of the unstated things in the design of things in the scsi
code is that there are no arrays or large structures allocated off the
stack. The DMA pool generally serves as a reservoir of memory which can
be allocated atomicly (whether it needs to be DMA-able or not). Also, in the
1542 driver, I don't allow further interrupts while I am in the interrupt
handler. I just sit in there and keep looping as long as there is something
that needs to be done, and then return when there is nothing to do.

-Eric

-- 
"The woods are lovely, dark and deep.  But I have promises to keep,
And lines to code before I sleep, And lines to code before I sleep."