cloudius-systems / osv

OSv, a new operating system for the cloud.
osv.io
Other
4.12k stars 605 forks source link

Detect exception/interrupt stack overflow #1339

Open wkozaczuk opened 1 week ago

wkozaczuk commented 1 week ago

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.