-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Code sections of ocamlopt-generated executables must remain readable #12372
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
Conversation
This is required for marshaling of function closures. OpenBSD 7.3 makes code sections non-readable by default.
cc @shindere |
The comment in `configure..ac` refers to `OCaml-generated executables`
whereas the PR title and commit message only mention ocamlopt. Which one
of the two is correct?
The `AS_CASE` is on `$host`. Although I think it won't make a bitg
difference yet, wouldn't it be more accurate to do the test on
`$target`?
And finally, if I am reading the pattern correctly I understand that it
will detect only versions 8 and 9 of OpenBSD but that the flag won't be
added on version 10 and above. Is the OpenBSD release cycle such that
it's reasonoable to not take this into account?
One thing worth exploring is `ax_compare_version.html`. We could add
that file to our `build-aux` directory and use the macros it provides
and which look nicer, especially given that we do version comparison in
several places.
|
Probably neither, but the former is less wrong than the latter. If I read the script correctly,
All the case analyses that affect
By the time OpenBSD 10 is released, I fully expect them to have changed their security model and added custom linker flags several times. We'll adapt as needed. |
Ran the testsuite on OpenBSD-current/amd64 where it passes with this PR (and fails without). Will try on OpenBSD/arm64 tomorrow; not got access to that machine right now. |
Thanks! FYI, the Jenkins CI at Inria includes an amd64/OpenBSD machine, but no other OpenBSD configuration. |
Ping! This PR is being considered for inclusion in 5.1, so we have to decide quickly whether it's good enough for that . |
I just finishing triaging what's going on; we were triggering a base OS bug on OpenBSD 7.3 as well!
So in summary, this PR fixes OpenBSD on amd64, and https://github.com/avsm/ocaml/tree/openbsd-no-execute-only has the extra commit to fix it on arm64 (for the next release of OpenBSD) as well. I'll follow up separately by email about getting OpenBSD/arm64 added to the Inria testing matrix... |
Minor tweak: to the arm64 fix to use the same OS version detection as the other check: avsm@32fe3b9 |
Just one additional question.
Wouldn't it be worth checking which compiler is used before adding
compiler flags? Just in case the user had overriden the default
compiler.
|
This is usually true on operating systems like Linux, but on OpenBSD the base system depends on the distributed compiler included with that release. There are often a number of OpenBSD-specific changes; see gcc-local(1) and clang-local(1). So there is no expectation that a third-party compiler will work out-of-the-box without having some of those local adaptations taken into account, and therefore no need to check for that in our OCaml configure scripts. |
Okay, many thanks for your feedback on that, Anil.
Since you have done much more testing on this PR than me I'd feel more
comfortable if it is you (rather thanme) who approve it.
I think it would have been nice to use the version-comparison macro
refered to earlier.
|
It's a linker flag, so it doesn't matter which C compiler is used. |
Xavier Leroy (2023/07/17 07:37 -0700):
> Wouldn't it be worth checking which compiler is used before adding compiler flags?
It's a linker flag, so it doesn't matter which C compiler is used.
OK, got it.
|
Co-authored-by: Miod Vallat <miod@tarides.com>
Merged in this PR, thanks. I'm running a round of CI precheck before merging this PR. |
94274ac
to
876a578
Compare
Marshaling of function closures requires that the code sections of executables and shared objects remain readable. The default in OpenBSD >= 7.3 is to make code sections non-readable and execute-only. Co-authored-by: Anil Madhavapeddy <anil@recoil.org> Co-authored-by: Miod Vallat <miod@tarides.com> (cherry picked from commit ca28168)
Merged and cherry-picked to 5.1 |
Marshaling of function closures requires that the code sections of executables and shared objects remain readable. The default in OpenBSD >= 7.3 is to make code sections non-readable and execute-only. Co-authored-by: Anil Madhavapeddy <anil@recoil.org> Co-authored-by: Miod Vallat <miod@tarides.com> (cherry picked from commit ca28168)
Backported to the 4.14 branch (49bff4c). |
Backported to the 4.14 LTS branch (49bff4c), as it is required for 4.14 to work on OpenBSD. |
This is required for marshaling of function closures. OpenBSD 7.3 makes code sections non-readable by default. This PR adds magic to
configure
so as to detect OpenBSD >= 7.3 and activate the--no-execute-only
linker flag.