Hardening ELF binaries using Relocation Read-Only (2019)
1–10 of 31 posts
Re: Hardening ELF binaries using Relocation Read-Only (2019)
#2Re: Hardening ELF binaries using Relocation Read-Only (2019)
#3Re: Hardening ELF binaries using Relocation Read-Only (2019)
#4Glad to see this security by default progress from RedHat. I was surprised to not see a discussion of the costs, though. How much slower is program startup for large programs now that all these functions are unconditionally looked up at the start instead of lazily? Even functions that are never called are now looked up.
> Using full RELRO has a slight performance impact during application startup (as the linker has to populate the GOT entries before entering the main function).
In general, the difference for a large application is non-negligible and one should carefully consider the impact before enabling this feature by default.
Re: Hardening ELF binaries using Relocation Read-Only (2019)
#5this is my template for most Linux projects (except when "something else" is needed :)) ... please don't copy paste without certainty of what it does:
CFLAGS_BASE := -c -O2 -Wall -Werror -Wpedantic -pipe $(CFLAGS)
CFLAGS_HARD := -fPIE -Wformat-security -fstack-protector-strong --param=ssp-buffer-size=4 -fcf-protection -Wimplicit-fallthrough -D_FORTIFY_SOURCE=2
CFLAGS_DEBUG := -g3 -gdwarf-2
CFLAGS_RELEASE := -s -fomit-frame-pointer -march=native
LDFLAGS := -Wl,-z,now -Wl,-z,relro -Wl,-z,defs -Wl,-pie -Wl,--no-copy-dt-needed-entries
LDFLAGS_HMALLOC := -L/usr/local/lib -lhardened_malloc # see https://github.com/GrapheneOS/hardened_malloc
don't get security advise from random strangers like me on HN, also don't forget to always ship code with an apparmor profile and lock down the systemd unit file with seccomp filters and other hardening options (even RH is just another IBM company now, they have excellent docs on this and some impressive appsec/security people on their payroll https://www.redhat.com/sysadmin/mastering-systemd). Also after learning about systemd hardening this was the time I stopped worrying and learned to love systemd. (actually just joking I still hate systemd with a passion)Re: Hardening ELF binaries using Relocation Read-Only (2019)
#6This might not be exactly the same as how it is implemented in Linux but at least to me seeing all the code involved from start to finish is a much better way to understand the concept.
Re: Hardening ELF binaries using Relocation Read-Only (2019)
#7Glad to see this security by default progress from RedHat. I was surprised to not see a discussion of the costs, though. How much slower is program startup for large programs now that all these functions are unconditionally looked up at the start instead of lazily? Even functions that are never called are now looked up.
There’s a one sentence nod to this at the bottom: > Using full RELRO has a slight performance impact during application startup (as the linker has to populate the GOT entries before entering the main function). In general, the difference for a large application is non-negligible and one should carefully consider the impact before enabling this feature by default.
And because of that they enabled it for all binaries on Fedora. The fedora users are now testing whether it's possible to activate it by default.
Re: Hardening ELF binaries using Relocation Read-Only (2019)
#8last time I checked the Debian and Gentoo hardening guides relro/pie were standard practice. I can't remember the time we didn't use it and I've been around for a minute. this is my template for most Linux projects (except when "something else" is needed :)) ... please don't copy paste without certainty of what it does: CFLAGS_BASE := -c -O2 -Wall -Werror -Wpedantic -pipe $(CFLAGS) CFLAGS_HARD := -fPIE -Wformat-secur…
Re: Hardening ELF binaries using Relocation Read-Only (2019)
#9Glad to see this security by default progress from RedHat. I was surprised to not see a discussion of the costs, though. How much slower is program startup for large programs now that all these functions are unconditionally looked up at the start instead of lazily? Even functions that are never called are now looked up.
There’s a one sentence nod to this at the bottom: > Using full RELRO has a slight performance impact during application startup (as the linker has to populate the GOT entries before entering the main function). In general, the difference for a large application is non-negligible and one should carefully consider the impact before enabling this feature by default.
Naturally one might consider it doesn't matter for the use case at hand.
Re: Hardening ELF binaries using Relocation Read-Only (2019)
#10last time I checked the Debian and Gentoo hardening guides relro/pie were standard practice. I can't remember the time we didn't use it and I've been around for a minute. this is my template for most Linux projects (except when "something else" is needed :)) ... please don't copy paste without certainty of what it does: CFLAGS_BASE := -c -O2 -Wall -Werror -Wpedantic -pipe $(CFLAGS) CFLAGS_HARD := -fPIE -Wformat-secur…