Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compiler flags suggested by security review (#4368) #177

Merged
merged 4 commits into from
Oct 18, 2018
Merged

Add compiler flags suggested by security review (#4368) #177

merged 4 commits into from
Oct 18, 2018

Conversation

kf6gpe
Copy link
Contributor

@kf6gpe kf6gpe commented Oct 5, 2018

In 4368 it's recommended that we build binaries with the following flags that provide security benefits:

  • stack cookies to prevent stack overflow (-fstack_protector_all)
  • read-only relocations (-Wl,z,relro),
  • BIND_NOW to protect the global offset table from being overwritten (-Wl,-z,now)
  • Position independent executable code generation (-fPIE, -pie).
  • FORTIFY_SOURCE to protect from common misuse of memory and string functions. There is an existing comment that FORTIFY_SOURCE appears to have problems with clang, but that's with an unused optimization level (-O1) that does not appear to be pertinent to this work. However, I left in the comment should we choose to adjust the optimization levels in the future.

(For a more detailed if slightly dated explanation of what these flags do, see here.)

Due to size constraints, I did not add the suggested optimization flag (-O2) listed in the original issue, per discussions with @goderbauer on the issue.

Changes were applied to the Android binary compilation flags, and relevant changes applied to the iOS compilation flags (stack cookies, offset table and read-only relocations are not supported by the iOS tools). Note that iOS generates code in a position-independent executable way by default, but I explicitly add those directives in a new iOS flag block for future reviewers.

@kf6gpe kf6gpe self-assigned this Oct 5, 2018
if (enable_lto) {
lto_flags += [ "-flto" ]
}
# TODO(goderbauer): re-enable when https://github.com/flutter/flutter/issues/21686 is fixed
Copy link
Member

Choose a reason for hiding this comment

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

This looks like a bad merge? I think LTO should stay on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I think I was too far behind in the tree. Lemme go back and fix that.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

Hopefully this will not impact performance or size negatively.

@mit-mit
Copy link
Member

mit-mit commented Oct 17, 2018

@kf6gpe are we ready to merge this?

@kf6gpe
Copy link
Contributor Author

kf6gpe commented Oct 17, 2018

Oh! Yes, please --- was waiting for an LGTM from @Hixie because it was kind of a sweeping change. Let me resolve the conflicts, and see what he thinks.

@chinmaygarde
Copy link
Member

-Wa,--noexecstack was reverted in #185 due to buildbot failures on Mac. Issue tracked in flutter/flutter#23606.

Also, please format GN file updates using gn format.

goderbauer added a commit to goderbauer/buildroot that referenced this pull request Oct 29, 2018
goderbauer added a commit that referenced this pull request Oct 29, 2018
…" (#186)

This reverts commit 9bbd435.

This caused major regressions, see flutter/flutter#23678.

In the future, we can check the flags individually to see which we can add without regressing our benchmarks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants