forked from sonic-net/sonic-swss-common
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix swss-common binskim errors (sonic-net#817)
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: 1. clone latest code from https://github.com/microsoft/binskim/tree/main 2. build by run 'BuildAndTest.cmd' command 3. Open this PR build aritfact, download all x86 debs and extract file to local device. 4. Run scan with following command and confirm issue fixed: .\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\* ### Description for the changelog Fix swss-common binskim errors.
- Loading branch information
Showing
6 changed files
with
10 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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