Skip to content

Conversation

droberts195
Copy link
Contributor

This change adds the stack protector, relro and fortify source
options to the commands used to build the 3rd party libraries
we use on Linux.

(We already used these options when building our own code.)

This change adds the stack protector, relro and fortify source
options to the commands used to build the 3rd party libraries
we use on Linux.

(We already used these options when building our own code.)
ENV PATH /usr/local/gcc73/bin:/usr/bin:/bin:/usr/sbin:/sbin

# For compiling in C++14 mode
# For compiling in C++14 mode with hardening and optimisation
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that optimisation was not added in this commit. If CFLAGS is not specified then the configure scripts use a default value for it, and this invariably includes optimisation. It's only because we are now specifying CFLAGS that we have to explicitly add the optimisation option now.

```
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we have a second define here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s fine to have two (or more) defines here. They become multiple -D arguments on the compiler command line, which is a very usual thing to have.

./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS
./b2 -j6 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now
sudo env PATH="$PATH" ./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

echo " Building..."
./b2 -j$NUMCPUS --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS > b2_make.log 2>&1
./b2 install --prefix=/usr/local/gcc73 --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS > b2_make_install.log 2>&1
./b2 -j$NUMCPUS --layout=versioned --disable-icu pch=off optimization=speed inlining=full define=BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS define=_FORTIFY_SOURCE=2 cxxflags=-std=gnu++14 cxxflags=-fstack-protector linkflags=-Wl,-z,relro linkflags=-Wl,-z,now > b2_make.log 2>&1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

second define in this and the following line is well (if it is an issue)

Copy link
Contributor

@dimitris-athanasiou dimitris-athanasiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@droberts195 droberts195 merged commit 6dc74bf into elastic:master Apr 8, 2019
@droberts195 droberts195 deleted the harden_3rd_party branch April 8, 2019 07:56
droberts195 added a commit to droberts195/ml-cpp that referenced this pull request Apr 8, 2019
This change adds the stack protector, relro and fortify source
options to the commands used to build the 3rd party libraries
we use on Linux.

(We already used these options when building our own code.)

Backport of elastic#453
droberts195 added a commit that referenced this pull request Apr 8, 2019
This change adds the stack protector, relro and fortify source
options to the commands used to build the 3rd party libraries
we use on Linux.

(We already used these options when building our own code.)

Backport of #453
droberts195 added a commit to droberts195/ml-cpp that referenced this pull request Apr 24, 2019
This is a follow on to elastic#453

The stack protector, relro and fortify source options
need to be used when building gcc, because we redistribute
two libraries that are built as part of it, namely
libgcc_s.so.1 and libstdc++.so.6.
droberts195 added a commit that referenced this pull request Apr 25, 2019
This is a follow on to #453

The stack protector, relro and fortify source options
need to be used when building gcc, because we redistribute
two libraries that are built as part of it, namely
libgcc_s.so.1 and libstdc++.so.6.
droberts195 added a commit to droberts195/ml-cpp that referenced this pull request Apr 25, 2019
This is a follow on to elastic#453

The stack protector, relro and fortify source options
need to be used when building gcc, because we redistribute
two libraries that are built as part of it, namely
libgcc_s.so.1 and libstdc++.so.6.

Backport of elastic#470
droberts195 added a commit that referenced this pull request Apr 25, 2019
This is a follow on to #453

The stack protector, relro and fortify source options
need to be used when building gcc, because we redistribute
two libraries that are built as part of it, namely
libgcc_s.so.1 and libstdc++.so.6.

Backport of #470
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants