Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect exception/interrupt stack overflow #1339

Open
wkozaczuk opened this issue Nov 13, 2024 · 0 comments
Open

Detect exception/interrupt stack overflow #1339

wkozaczuk opened this issue Nov 13, 2024 · 0 comments

Comments

@wkozaczuk
Copy link
Collaborator

When testing some Makefile changes with debug build on Fedora 37 with GCC 12, I discovered that OSv crashes or hangs in many scenarios. After some digging, I found the culprit lies in too small interrupt stack which is only 1 page large on x86_64 - probably the code generated with -O0 needs larger stack. Increasing the interrupt stack to 2 pages fixes the issue.

Given how small the interrupt stack is, we probably could at least introduce some "canary"-based type of solution similar to what we employ with the small syscall stack. Right after handling an interrupt in the interrupt() routing (see arch/x64/exceptions.cc) we could check the canary value and abort if overflow is detected.

wkozaczuk added a commit that referenced this issue Nov 13, 2024
…g mode

When building OSv with newer GCC (>= 12) in debug mode, the interrupt
handler running on dedicated stack needs more than 1 page otherwise it
causes overflow. Similarly, the code setting up large syscall stack,
running on small 2K stack runs of of space as well.

To fix this, we increase the interrupt stack size to 8K and small
syscall stack size to 8K when building in debug mode (#ifndef NDEBUG).

Ideally, in long term we should implement some canary-based logic to
detect interrupt stack overflow as the issue #1339 explains.

Ref #1339

Signed-off-by: Waldemar Kozaczuk <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant