-
Notifications
You must be signed in to change notification settings - Fork 7
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
Warn if compartment call returns void #34
Comments
Hi, |
I think it is worth to take the c++ cases into account (non static method, constructor/destructor, lambda ?, etc.). But it would be better to write another ticket for that. |
I'm not sure what it would even mean to expose a constructor across a compartment boundary. A factory method, maybe, but what would the security model be for a constructor? Non-static methods can't be compartment exports, because they need to in the vtable and the ABI does not allow that. It would be possible to make a lambda's call operator a cross-compartment call, but there's no way of exposing that in the source language. |
I'll open a ticket about generating an error when non static methods are used as compartment entry points. (Or you can if you have other edge cases in mind). There are more things to mention as I progress:
|
To the first, yes this makes no sense for function pointers. Function pointers must use the Cheri callback convention. They are not (and cannot be) explicitly tied to a compartment. I think showing the warning twice to start with is fine for a first cut. |
I wrote a first version for cheri_compartment. I reported the duplicate attribute problem caused by There are still to support cheri_ccall and cheri_ccallback. But this is a little bit more complicated than expected as the attribute is added to the AST in a different part where it's more difficult to also add an additional WarnUnusedResult attr. Emitting a diagnosis about void return type could easily be done though. |
Keeping this open until the warning is enabled by default. |
We also need a mechanism for silencing it before it can be on by default. There are some cases (callbacks, compartment entry points) where a void return is fine. |
Would |
It would be good if
clang
would warn if the return type of a compartment call isvoid
. Compartment calls can fail unexpectedly and return-1
(e.g. due to trusted stack exhaustion). Callers should be aware of and check for this, therefore it is never appropriate for a compartment call to returnvoid
. For the same reason we should also consider automatically adding thenodiscard
attribute to compartment calls.The text was updated successfully, but these errors were encountered: