Skip to content

debian/rules: add full OpenSSF compiler hardening baseline - #48

Open
xq9mend wants to merge 1 commit into
sonic-net:masterfrom
xq9mend:fix/gcc-hardening-openssf
Open

debian/rules: add full OpenSSF compiler hardening baseline#48
xq9mend wants to merge 1 commit into
sonic-net:masterfrom
xq9mend:fix/gcc-hardening-openssf

Conversation

@xq9mend

@xq9mend xq9mend commented Jul 2, 2026

Copy link
Copy Markdown

Why I did it

Enable compiler and linker hardening flags aligned with the OpenSSF Compiler Options Hardening Guide for C and C++.

Work item tracking
  • Microsoft ADO:

How I did it

Add to debian/rules:

  • hardening=+all,+bindnow: full RELRO, stack-protector-strong, format checks, PIE
  • FORTIFY_SOURCE=3: upgraded from dpkg default of 2
  • _GLIBCXX_ASSERTIONS: C++ stdlib bounds checking
  • -fstack-clash-protection: stack clash mitigation
  • -fcf-protection=full (amd64) / -mbranch-protection=standard (arm64): CFI
  • Production safety flags: -fno-delete-null-pointer-checks, -fno-strict-overflow, -fno-strict-aliasing, -ftrivial-auto-var-init=zero (GCC >= 12 only)
  • Linker: -Wl,-z,nodlopen -Wl,-z,noexecstack -Wl,--as-needed

How to verify it

CI build passes. Verify with objdump -d or checksec on produced binaries.

Description for the changelog

enable OpenSSF compiler hardening baseline

Link to config_db schema for YANG changes

N/A

@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

@xq9mend

xq9mend commented Jul 3, 2026

Copy link
Copy Markdown
Author

cc @donaldsharp @louberger — requesting your review on this OpenSSF compiler hardening change.

Upgrade FORTIFY_SOURCE to level 3 (dpkg default is =2). The -U flag
clears the existing =2 before setting =3 to avoid duplicate-definition
warnings.

Signed-off-by: xq9mend <xq9mend@users.noreply.github.com>
@xq9mend
xq9mend force-pushed the fix/gcc-hardening-openssf branch from 4313eae to d3e6cb9 Compare July 25, 2026 09:21
@mssonicbld

Copy link
Copy Markdown
Collaborator

/azp run

@azure-pipelines

Copy link
Copy Markdown
No pipelines are associated with this pull request.

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.

2 participants