-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Support for Full RELRO #11046
Comments
I just got the issue in NetBSD 10.0 where RELRO got enabled. I could compile the crystal compiler itself (from a cross compiled & linked bootstrap) without any issues, but trying to compile the std specs, I ran into runtime missing symbols because of RELRO (missing xmlXYZ or _unwindXYZ symbol). It took me a while to notice that the Apparently we usually support RELRO, but it seems that some external libraries may not be compatible? I can enforce Note: it may be something entirely different. We should verify the behavior on different platforms. |
Wouldn't RELRO support be something that pkgconfig should know about? 🤔 |
RELRO is a property of the final executable, set by the linker, just like PIE. Libraries may not be compatible for different reasons. At least this is how the Searching |
Something very weird is that I could compile a Crystal compiler with RELRO but trying to compiler There's something fishy. Maybe it's another library that gets linked in that's creating issues. |
Today the std specs compiled in my NetBSD 10.0 VM with EDIT: and suddenly linking fails 🙃 |
Oh my: if |
Nope, I only get the above issue when I link I tried on Ubuntu 22.04, and I can compile and run Except for some corner cases on some platforms, it seems that Crystal is compatible with full RELRO 🤷 |
Oh, the link issue on netbsd disappears if I use |
The LibC bindings for NetBSD were a bit wrong and some std specs also didn't work as expected. The segfault handler is also broken on NetBSD (the process crashes with SIGILL after receiving SIGSEGV). With these fixes + pending specs I can run the std and compiler test suites in a NetBSD 10.0 VM. **Caveat**: the pkgsrc for LLVM enforces partial RELRO and linking the std specs from crystal fails. You must pass `--single-module` for the executable to be able to start without missing runtime symbols from libxml2. See #11046.
I'm running the Pop! OS flavor of Ubuntu 22.04 with LLVM 18 and $ make .build/crystal
$ readelf -a .build/crystal | egrep 'RELRO|BIND_NOW'
GNU_RELRO 0x0000000001ad66d0 0x0000000001ad86d0 0x0000000001ad86d0
0x000000000000001e (FLAGS) BIND_NOW From the hardening pkgsrc page from NetBSD, it means that full RELRO has been enabled. Passing So: Crystal supports full RELRO, with maybe some caveat (e.g. I guess there are little to no reasons to not enable the feature by default... but maybe it's already enabled system wide today (as is the case on Ubuntu 22.04 apparently). |
The LibC bindings for NetBSD were a bit wrong and some std specs also didn't work as expected. The segfault handler is also broken on NetBSD (the process crashes with SIGILL after receiving SIGSEGV). With these fixes + pending specs I can run the std and compiler test suites in a NetBSD 10.0 VM. **Caveat**: the pkgsrc for LLVM enforces partial RELRO and linking the std specs from crystal fails. You must pass `--single-module` for the executable to be able to start without missing runtime symbols from libxml2. See crystal-lang#11046.
I was messing around with adding a package to AUR and noticed namcap was producing a warning:
ELF file ('usr/bin/oq') lacks FULL RELRO, check LDFLAGS
, which apparently relates to an ELF hardening feature:It seems this feature is enabled by default in Rust since Oct 2017. Probably wouldn't hurt to do the same in Crystal land? Could reference this PR: rust-lang/rust#43170.
The text was updated successfully, but these errors were encountered: