New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.
Starred by 11 users
Status: Verified
Owner:
Last visit 26 days ago
Closed: Jan 2013
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Chrome , Mac
Pri: 2
Type: Bug



Sign in to add a comment
Evaluate building with hardened binary flags
Project Member Reported by evan@chromium.org, Sep 13 2010 Back to list
Debian has a nice bundle of gcc flags to harden binaries:
http://lists.debian.org/debian-devel-announce/2008/01/msg00006.html
http://wiki.debian.org/Hardening

The list is:
DEB_BUILD_HARDENING_FORMAT (gcc/g++ -Wformat -Wformat-security)
DEB_BUILD_HARDENING_FORTIFY (gcc/g++ -D_FORTIFY_SOURCE=2)
DEB_BUILD_HARDENING_STACKPROTECTOR (gcc/g++ -fstack-protector)
DEB_BUILD_HARDENING_PIE (gcc/g++ -fPIE -pie)
DEB_BUILD_HARDENING_RELRO (ld -z relro)
DEB_BUILD_HARDENING_BINDNOW (ld -z now)

PS: We should consider these on Mac as well.
 
Comment 1 by f...@sofaraway.org, Sep 14 2010
In Ubuntu, i'm building with the so-called hardening-wrapper.
It means having the hardening-wrapper package installed at build-time,
and building the using the debian/ubuntu tools with DEB_BUILD_HARDENING=1
(it diverts the toolchain to add flags so packages don't have to be tweaked
further).
Details are here: https://wiki.ubuntu.com/Security/HardeningWrapper

===
I build trunk and all the channels (in PPAs) with that wrapper, on:
- {maverick,lucid,karmic} x {i386,amd64}
- {jaunty,hardy} x {i386,amd64,lpia}

I also build the stable releases on {maverick,lucid} x {i386,amd64,armel} (for the official distributions, not PPAs)
===

It works reasonably well except:
- on amd64 for both jaunty and hardy

http://launchpadlibrarian.net/55436522/buildlog_ubuntu-hardy-amd64.chromium-browser_6.0.472.55~r58392-0ubuntu1~ucd1~hardy_FAILEDTOBUILD.txt.gz

  LINK(target) out/Release/chrome
/usr/bin/ld.real: out/Release/obj.target/native_client/src/trusted/service_runtime/arch/x86_64/libservice_runtime_x86_64.a(nacl_tls_64.o): relocation R_X86_64_TPOFF32 against `nacl_thread_index' can not be used when making a shared object; recompile with -fPIC
out/Release/obj.target/native_client/src/trusted/service_runtime/arch/x86_64/libservice_runtime_x86_64.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
make[1]: *** [out/Release/chrome] Error 1

- on armel (probably all dists, just tested with maverick and lucid)

http://launchpadlibrarian.net/55522699/buildlog_ubuntu-maverick-armel.chromium-browser_6.0.472.55~r58392-0ubuntu1_FAILEDTOBUILD.txt.gz

  LINK(target) out/Release/chrome
/usr/bin/ld.bfd.real: out/Release/obj.target/skia/libskia.a(SkBlurDrawLooper.o)(.text._ZN16SkBlurDrawLooper10CreateProcER23SkFlattenableReadBuffer[SkBlurDrawLooper::CreateProc(SkFlattenableReadBuffer&)]+0x6): unresolvable R_ARM_THM_CALL relocation against symbol `operator new(unsigned int)@@GLIBCXX_3.4'
/usr/bin/ld.bfd.real: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status
make[1]: *** [out/Release/chrome] Error 1

(you may want to copy the logs here, i can't guaranty their stability)
Comment 2 by agl@chromium.org, Sep 14 2010
The R_X86_64_TPOFF32 is a linker bug: http://sourceware.org/bugzilla/show_bug.cgi?id=10434

As for the ARM build: it's coming from a static non-POD object, which always suggests problems. I can't see any explicit |new| calls however, and I don't have an ARM build setup to be able to play around.
Comment 3 by karen@chromium.org, Sep 14 2010
Labels: Mstone-X
Comment 4 by f...@sofaraway.org, Sep 14 2010
apparently, the R_ARM_THM_CALL issue is on maverick only, not lucid.
Comment 5 by kerz@chromium.org, Sep 15 2010
Status: Assigned
Comment 6 by mark@chromium.org, Sep 15 2010
We build with some of these on the Mac now. I think we already have bugs covering everything else we can add.

For example, PIE confused Valgrind, so we had to turn it off.
Comment 7 by wbr...@gmail.com, Oct 4 2010
There could be build switch, which enables PIE. PIE should have better performance than PIC. Average user doesn't use Valgrind.
 Issue 67821  has been merged into this issue.
Cc: phajdan....@gtempaccount.com
Comment 10 by evan@chromium.org, Sep 20 2011
Owner: ----
Not going to get to this before I go on leave, sorry.
Comment 11 by evan@chromium.org, Jun 11 2012
Cc: -evan@chromium.org
(Un-ccing myself from bugs.)
Project Member Comment 12 by bugdroid1@chromium.org, Nov 20 2012
The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=168889

------------------------------------------------------------------------
r168889 | phajdan.jr@chromium.org | 2012-11-20T22:35:25.500644Z

Changed paths:
   M http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?r1=168889&r2=168888&pathrev=168889

Use more hardening flags:

-D_FORTIFY_SOURCE=2
-Wl,-z,now (aka BIND_NOW)
-Wl,-z,relro (read-only relocation tables)

BUG= 55439 

Review URL: https://codereview.chromium.org/11411022
------------------------------------------------------------------------
Project Member Comment 13 by bugdroid1@chromium.org, Dec 11 2012
The following revision refers to this bug:
    http://src.chromium.org/viewvc/chrome?view=rev&revision=172225

------------------------------------------------------------------------
r172225 | phajdan.jr@chromium.org | 2012-12-11T01:54:58.179229Z

Changed paths:
   M http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi?r1=172225&r2=172224&pathrev=172225

Only build with _FORTIFY_SOURCE in Release mode.

This prevents build failures on Fedora.

BUG= 16257 ,  55439 

Review URL: https://codereview.chromium.org/11490019
------------------------------------------------------------------------
Cc: jorgelo@chromium.org
Should we close this bug and eventually open a new one for the remaining flags?
Owner: phajdan.jr@chromium.org
Status: Fixed
Yup, closing.
Labels: VerifyIn-26
Project Member Comment 17 by bugdroid1@chromium.org, Mar 10 2013
Labels: -Area-Internals Cr-Internals
Comment 18 by krisr@chromium.org, Mar 12 2013
Status: Verified
Sign in to add a comment