Skip to content
This repository was archived by the owner on Mar 28, 2018. It is now read-only.

Makefile: Add build hardening with -fPIE flag#775

Merged
dlespiau merged 1 commit intomasterfrom
sboeuf/enable_fPIE_flag
Mar 27, 2017
Merged

Makefile: Add build hardening with -fPIE flag#775
dlespiau merged 1 commit intomasterfrom
sboeuf/enable_fPIE_flag

Conversation

@sboeuf
Copy link
Copy Markdown

@sboeuf sboeuf commented Mar 24, 2017

Adding the -fPIE -pie flags in order to harden the security. It creates our binary as a Position Independant Executable, and takes advantage of ASLR, making ROP attacks much harder to perform.

See https://wiki.debian.org/Hardening for further details.

@sboeuf sboeuf force-pushed the sboeuf/enable_fPIE_flag branch from ef33c19 to 561a912 Compare March 24, 2017 20:07
@chavafg
Copy link
Copy Markdown
Contributor

chavafg commented Mar 27, 2017

qa-passed

Approved with PullApprove

@dlespiau
Copy link
Copy Markdown
Contributor

Seems like the build with clang is failing and needs to be looked at.

@sboeuf
Copy link
Copy Markdown
Author

sboeuf commented Mar 27, 2017

@dlespiau yes I have noticed clang build is not passing. It is due to following warnings considered as errors:
clang: warning: argument unused during compilation: '-pie'

Any idea how to properly solve this ?

@dlespiau
Copy link
Copy Markdown
Contributor

We can always adapt the flags depending on the compiler we configure the compilation with (CC=gcc or CC=clang). -fPIE -pie for gcc, -fPIE for clang.

@sboeuf
Copy link
Copy Markdown
Author

sboeuf commented Mar 27, 2017

Yes makes sense. Supposed to do that from configure.ac ?

@dlespiau
Copy link
Copy Markdown
Contributor

Yes, configure.ac. Test CC in configure.ac, set a variable, eg. PIE_CFLAGS, to either -fPIE -pie or -fPIE and call AC_SUBST on it. USe $(PIE_CFLAGS) in Makefile.am. Turns out -pie seems to be a linker option. Not sure if that is needed in the link phase with clang.

@sboeuf
Copy link
Copy Markdown
Author

sboeuf commented Mar 27, 2017

@dlespiau I think I have just figured this out. No need to make a check according to the compiler used because clang actually support -pie link option. The warning/error message was about wrong use of -pie which is a link option as a compiler option.

Adding the -fPIE -pie flags in order to harden the security. It
creates our binary as a Position Independant Executable, and takes
advantage of ASLR, making ROP attacks much harder to perform.

See https://wiki.debian.org/Hardening for further details.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
@sboeuf sboeuf force-pushed the sboeuf/enable_fPIE_flag branch from 561a912 to 7815d4f Compare March 27, 2017 15:47
@sboeuf
Copy link
Copy Markdown
Author

sboeuf commented Mar 27, 2017

@dlespiau build is passing now ;)

@chavafg
Copy link
Copy Markdown
Contributor

chavafg commented Mar 27, 2017

qa-passed

@sboeuf
Copy link
Copy Markdown
Author

sboeuf commented Mar 27, 2017

@grahamwhaley @dlespiau maybe LGTM this one ?

@grahamwhaley
Copy link
Copy Markdown

grahamwhaley commented Mar 27, 2017

Yep, given the qa-passed and CI passed, and we are pretty sure about the -pie being a linker only cmd,
lgtm

Approved with PullApprove

@dlespiau
Copy link
Copy Markdown
Contributor

dlespiau commented Mar 27, 2017

I've checked locally and the resulting binaries seem to be relocatable and ready for ASLR.

lgtm.

@dlespiau
Copy link
Copy Markdown
Contributor

dlespiau commented Mar 27, 2017

lgtm? (maybe editing doesn't trigger pullaprove?)

Approved with PullApprove

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants