-
Notifications
You must be signed in to change notification settings - Fork 0
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
Make invoking IA2_DEFINE_SIG{ACTION,HANDLER}
inside a function a compile-time error
#459
Comments
It's surprising to me that this causes a segfault even in situations where (presumably) these signals are not being received. The macros in question define functions in assembly but should not actually cause any change in control flow until the signal handler runs. I would try debugging stack-mangling crashes like this using |
Ah, that's a good idea. Let me try |
dav1d uses |
Turns out the issue was that we had |
Everything works now that |
When the kernel makes a thread start executing from the signal handler it sets the PKRU to not have access to anything so it has to be a naked function. Otherwise the first few instructions accessing the stack will fault. |
IA2_DEFINE_SIGHANDLER
IA2_DEFINE_SIG{ACTION,HANDLER}
inside a function a compile-time error
Looks like we didn't initially make them naked functions because the asm statement is used for two functions with different signatures. This isn't a hard blocker for making them naked functions and triggering a compile-time error when these macros are invoked outside global scope, but the ARM case may complicate things. I'm not sure we need a wrapper to set x18 on ARM though. I think the kernel should leave x18 as-is (since it's also used for things like shadow call stack which should be all userspace) so it may be a non-issue. |
When I tried to use
IA2_DEFINE_SIGHANDLER
andIA2_SIGHANDLER
in compartmentalizingdav1d
, https://github.com/immunant/dav1d/blob/6483e57832c756096acab2c9f458676027cbb3b0/tools/dav1d.c#L287-L293, there was a segfault inIA2_DEFINE_SIGHANDLER
that corrupted the stack. Thus, I worked around this by simply commenting out that code and just didn't install the signal handler, as it's not too important fordav1d
. Am I doing something wrong here? I was trying to follow the docs atIA2-Phase2/docs/usage.md
Lines 81 to 86 in 94f890b
The text was updated successfully, but these errors were encountered: