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.
Fix swss-common binskim errors.
Work item tracking
Microsoft ADO (number only): 25090081
Why I did it
binskim scan report error BA3003, BA3004 and BA3011:
BA3003: The stack protector was not found. This may be because '--stack-protector-strong' was not used, or because it was explicitly disabled by '-fno-stack-protectors'.
BA3004: using debugging dwarf version '{1}'. The dwarf version 5 contains more information and should be used. To enable the debugging version 5 use '-gdwarf-5'.
BA3011: The BIND_NOW flag is missing from this binary, so relocation sections will not be marked as read only after the binary is loaded. An attacker can overwrite these to redirect control flow. Ensure you are compiling with the compiler flags '-Wl,-z,now' to address this.
How I did it
Add compiler flag and ld flag according to following document:
https://github.com/microsoft/binskim/blob/main/docs/BinSkimRules.md
For BA3003, add '-fstack-protector-strong' to configure.ac, which will enable GCC strong stack protect feature.
For BA3011, add LD flag '-Wl,-z,now' to every make file, this is because azure pipeline will overwrite global LD flag defined in config.ac for code coverage.
For BA3004, add '-gdwarf-5' to makefile.am for debug build generate better debug information.
How to verify it
Pass all UT.
Manually verify issue fixed with following steps:
.\bld\bin\x64_Release\net6.0\BinSkim.exe analyze .\sonic-swss-common\usr\bin*
.\bld\bin\x64_Release\net6.0\BinSkim.exe analyze .\sonic-swss-common\usr\lib*
Which release branch to backport (provide reason below if selected)
Description for the changelog
Fix swss-common binskim errors.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)