Yes, that can indeed be done and it's the VDSO code that nullplan was referring to (and on Linux, sigaction() has a SA_RESTORER flag for this purpose). The stack-based solution is done by Linux for uncooperative libcs (which were presumably used at some point in the past).Velko wrote:Back to the topic about stacks. I'm not getting why would one want to inject code into stack for returns from signal handler. Can not that be handled by having a bit of prologue and epilogue code in libc / glue library? Instead of registering the address of signal handler directly with kernel, store the signal handler callback in userspace variable and register the beginning of the prologue code instead.
Does anyone need executable stack?
Re: Does anyone need executable stack?
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].
Re: Does anyone need executable stack?
Was done. Nowadays the code exists only to mark the stack frame (apparently, GDB depends on it). The old trampoline is older than the VDSO, which is what is now used for uncooperative libcs. Indeed, not using SA_RESTORER could be beneficial, as the VDSO trampolines also get the exception handler frame attached to it that contains all the data on how to restore the higher frames.Korona wrote:The stack-based solution is done by Linux for uncooperative libcs (which were presumably used at some point in the past).
Carpe diem!
Re: Does anyone need executable stack?
You can also add the exception handling annotations to your libc (via CFI pseudo instructions). We do that to get stack traces across exception stacks in the kernel.
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].