[PATCH] parisc: Reduce probability of stack overflow

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Even with a 32 kB thread stack, I have seen instances where the thread stack overflowed on the mx3210 buildd.
Detection of stack overflow only occurs when we have an external interrupt.  When an external interrupt occurs,
we switch to the thread stack if we are not already on a kernel stack.  Then, registers and specials are saved to
the kernel stack.

The bug occurs in intr_return where interrupts are reenabled prior to returning from the interrupt.  This was done
incase we need to schedule or deliver signals.  However, it introduces the possibility that multiple external interrupts
may occur on the thread stack and cause a stack overflow.  These might not be detected and cause the kernel to
misbehave in random ways.

This patch changes the code to only reenable interrupts when we are going to schedule or deliver signals.  As a
result, we generally return from an interrupt before reenabling interrupts.  This minimizes the growth of the thread
stack.

This patch conflicts with the patch proposed by Helge here:
https://patchwork.kernel.org/patch/9970169/

In testing, I found that the thread stack can be 16 kB  when using an irq stack .  Without it, the thread stack needs
to be 32 kB.  Currently, the irq stack is 32 kB.  While it probably could be 16 kB, I would prefer to leave it as is for
safety.

Signed-off-by: John David Anglin <dave.anglin@xxxxxxxx>


Attachment: low-stack.d.stack
Description: Binary data


--
John David Anglin	dave.anglin@xxxxxxxx

[Index of Archives]     [Linux SoC]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux