enable hardening=+all and FORTIFY_SOURCE=3 - #349
Merged
Conversation
Add DEB_BUILD_MAINT_OPTIONS = hardening=+all to enable the full set of dpkg-buildflags hardening options (-fstack-protector-strong, RELRO, NX, etc.), and upgrade FORTIFY_SOURCE to level 3. dpkg sets FORTIFY_SOURCE=2 by default; the -U flag clears it before setting =3 to avoid duplicate-definition warnings. Signed-off-by: xq9mend <xq9mend@users.noreply.github.com>
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Collaborator
|
Hi, there are workflow run(s) waiting for approval, you may be first-time contributor. I will notify maintainers to help approve once PR is approved. Thanks! ---Powered by SONiC BuildBot
|
Contributor
|
what is the motivation of this pr? |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
Author
|
This PR enables the OpenSSF Compiler Options Hardening Guide baseline for this package. The flags improve exploit mitigation (stack clash protection, control-flow integrity, full RELRO, FORTIFY_SOURCE=3) and align with hardening standards recommended for production C/C++ code. Similar changes are being applied across sonic-net repos. |
Collaborator
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
lolyu
approved these changes
Jul 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why I did it
Enable the full set of dpkg-buildflags hardening options and upgrade FORTIFY_SOURCE to level 3.
hardening=+allenables-fstack-protector-strong, RELRO, NX, and related flags. FORTIFY_SOURCE=3 provides stronger compile-time buffer overflow detection than the dpkg default of =2. The-Uflag clears the existing =2 before setting =3 to avoid duplicate-definition warnings.How I did it
debian/rules: addDEB_BUILD_MAINT_OPTIONS = hardening=+allandDEB_CPPFLAGS_MAINT_APPEND = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3How to verify it
Build the package and confirm
-D_FORTIFY_SOURCE=3appears in compiler invocations.