Per a discussion with Roger at the Seattle hackfest I propose we enable gcc and ld hardening by default in 0.2.3.x when the ./configure is built with no options.
Shall I submit a patch that flips the options? So rather than --enable-gcc-hardening, we say --disable-gcc-hardening?
Or shall we just load the options and call it a day?
If someone else wants to bell the cat, I'm happy to defer to them.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items
0
Link issues together to show that they're related.
Learn more.
Implementing this would make a small part of #5024 (moved) implemented once we switch to tor 0.2.3.x for TBB, but not #5024 (moved) means all other stuff we bundle I think.
Yes, the Debian packaging sets the appropriate configure commands by default. In theory all other packagers should do so too, but because they don't, choosing this default for them when possible makes sense.
The patch breaks currently existing setups in a subtle way, so we can't apply it as is. If you call configure with --enable-gcc-hardening, the hardening gets turned off silently - obviously that's bad.
now both --enable and --disable should now work as intended.
There's two caveats with this patch still:
it doesn't detect whether gcc is in use and assumes that the compiler will ignore the flags it doesn't 'support'
it checks for the presence of the header 'elf.h' rather than the format of the executable produced (ie: the auto-detection magic won't work if you cross-compile or happen to have the elf headers installed)
That does indeed seem to work better, but I can confirm that building on clang, which doesn't support --param ssp-buffer-size=1 and -pie, gives a ton of warnings.
Okay, so what would be a way to detect this situation? We could just say, "If clang, don't use these options," but that wouldn't be so nice if some future version of clang starts supporting them. Other ideas?
I tried building something with AX_CFLAGS_GCC_OPTION, but it was too buggy; it didn't support --param ssp-buffer-size=1. So instead, I've hacked together a "bug5210" in my public repo, based on the one from nextgetns. Tested on linux with gcc and clang; then tried on OSX, where I had to add some more options to make clang shut up.
Please test and review and think about this stuff.
Looks like they've converged on the same options we have. That much is good.
I'm not convinced that explicitly grepping for a warning from clang is such a good idea: warnings change in the presence of localization.
The slowdown business is something we'll need to deal with in practice as we go. If stack-protector is hideously slow in some configurations, we might need to turn it off. If -fPIE is a big deal, we may need to add in a -fomit-frame-pointer for production builds of critical-path pieces of the code.
Incidentally, I don't think we really get protection from -fPIE unless any static library we link against is also built with -fPIE, right?
Some of this won't work on windows unless we do yet more magic; said magic is however a thing for a separate ticket.
Yuck. For me, this breaks on mingw+windows for some reason. Investigating... it looks like the -pie linker option breaks stuff there, but not immediately in a way that the configure script notices. (Stuff goes okay, and then when it wants to link libevent, it dies in a fire) I wonder if this is just my junky mingw setup, or if others have this issue with this branch too?
Ugh. The "-pie" part still makes the windows build crap out -- it doesn't detect that on windows, '-pie' is hopeless.. I have just gone and hard-disabled it when we're building for windows. Branch "bug5210" in my public repo is still the one to look at.
Tested this on osx 10.7 with llvm-gcc 4.2 and clang 3.1, seems to work fine on both. I'll start a compile of clang 3.0 when I have power again and try compiling tor with clang 3.0 with that, too