-
Notifications
You must be signed in to change notification settings - Fork 258
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
Conversation
build/config/compiler/BUILD.gn
Outdated
if (enable_lto) { | ||
lto_flags += [ "-flto" ] | ||
} | ||
# TODO(goderbauer): re-enable when https://github.com/flutter/flutter/issues/21686 is fixed |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
@kf6gpe are we ready to merge this? |
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. |
This reverts commit 9bbd435.
-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 |
…" (#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.
In 4368 it's recommended that we build binaries with the following flags that provide security benefits:
-fstack_protector_all
)-Wl,z,relro
),BIND_NOW
to protect the global offset table from being overwritten (-Wl,-z,now
)-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.