Skip to content
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

* BUGFIX: Fix command line parameter in documents: -Wl,z,relro with -Wl,-z,relro, and -Wl,z,now with -Wl,-z,now. #736

Merged
merged 2 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/BinSkimRules.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ The non-executable stack is not enabled for this binary, so '{0}' can have a vul

### Description

This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,relro' to enable this.
This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,relro' to enable this.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check

OK, so we clearly need to correct this typo, agreed and I've approved this change.

Isn't it true, though, that the -Wl convention is for passing linker args specifically from the Clang compiler? And that other compilers support directly passing things like the noexecstack flag?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved --- Thanks!

I think -Wl convention is for both:

https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Link-Options.html#Link-Options

-Wl,option
Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can use this syntax to pass an argument to the option. For example, -Wl,-Map,output.map passes -Map output.map to the linker. When using the GNU linker, you can also get the same effect with -Wl,-Map=output.map.

https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-wl-arg-arg2

-Wl,<arg>,<arg2>...
Pass the comma separated arguments in to the linker

I looked noexecstack rule, it currently use -z noexecstack, it will work, but -Wl,-z,noexecstack is said to the standard way and should be used instead. I think to create a PR to change it, let me know if sounds good @michaelcfanning
Also, the this noexecstack not only can be enabled by linker but also assembler -Wa,--noexecstack, let me know if you like me to test it out and include in the doc, "fix by ... or ..."


### Messages

Expand All @@ -166,7 +166,7 @@ The GNU_RELRO segment was present, so '{0}' is protected.

#### `Error`: Error

The GNU_RELRO segment is missing from this binary, so relocation sections in '{0}' 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,relro' to address this.
The GNU_RELRO segment is missing from this binary, so relocation sections in '{0}' 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,relro' to address this.

#### `InvalidMetadata`: NotApplicable

Expand All @@ -178,7 +178,7 @@ The GNU_RELRO segment is missing from this binary, so relocation sections in '{0

### Description

This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,now' to enable this.
This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,now' to enable this.

### Messages

Expand All @@ -188,7 +188,7 @@ The BIND_NOW flag was present, so '{0}' is protected.

#### `Error`: Error

The BIND_NOW flag is missing from this binary, so relocation sections in '{0}' 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.
The BIND_NOW flag is missing from this binary, so relocation sections in '{0}' 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.

#### `InvalidMetadata`: NotApplicable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class EnableReadOnlyRelocations : ElfBinarySkimmer
/// This check ensures that some relocation data is marked as read only after
/// the executable is loaded, and moved below the .data section in memory.
/// This prevents them from being overwritten, which can redirect control flow.
/// Use the compiler flags '-Wl,z,relro' to enable this.
/// Use the compiler flags '-Wl,-z,relro' to enable this.
/// </summary>
public override MultiformatMessageString FullDescription => new MultiformatMessageString { Text = RuleResources.BA3010_EnableReadOnlyRelocations_Description };

Expand Down
2 changes: 1 addition & 1 deletion src/BinSkim.Rules/ElfRules/BA3011.EnableBindNow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class EnableBindNow : ElfBinarySkimmer
/// This check ensures that some relocation data is marked as read only after
/// the executable is loaded, and moved below the .data section in memory.
/// This prevents them from being overwritten, which can redirect control flow.
/// Use the compiler flags '-Wl,z,now' to enable this.
/// Use the compiler flags '-Wl,-z,now' to enable this.
/// </summary>
public override MultiformatMessageString FullDescription => new MultiformatMessageString { Text = RuleResources.BA3011_EnableBindNow_Description };

Expand Down
8 changes: 4 additions & 4 deletions src/BinSkim.Rules/RuleResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/BinSkim.Rules/RuleResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -425,19 +425,19 @@ Modules did not meet the criteria: {1}</value>
<value>Stack protector was found on '{0}'. However, if you are not compiling with '--stack-protector-strong', it may provide additional protections.</value>
</data>
<data name="BA3010_EnableReadOnlyRelocations_Description" xml:space="preserve">
<value>This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,relro' to enable this.</value>
<value>This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,relro' to enable this.</value>
</data>
<data name="BA3010_Error" xml:space="preserve">
<value>The GNU_RELRO segment is missing from this binary, so relocation sections in '{0}' 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,relro' to address this.</value>
<value>The GNU_RELRO segment is missing from this binary, so relocation sections in '{0}' 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,relro' to address this.</value>
</data>
<data name="BA3010_Pass" xml:space="preserve">
<value>The GNU_RELRO segment was present, so '{0}' is protected.</value>
</data>
<data name="BA3011_EnableBindNow_Description" xml:space="preserve">
<value>This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,now' to enable this.</value>
<value>This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,now' to enable this.</value>
</data>
<data name="BA3011_Error" xml:space="preserve">
<value>The BIND_NOW flag is missing from this binary, so relocation sections in '{0}' 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.</value>
<value>The BIND_NOW flag is missing from this binary, so relocation sections in '{0}' 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.</value>
</data>
<data name="BA3011_Pass" xml:space="preserve">
<value>The BIND_NOW flag was present, so '{0}' is protected.</value>
Expand Down
1 change: 1 addition & 0 deletions src/ReleaseHistory.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Upgrade Sarif.Sdk by updating submodule from [fc9a9df to 698adb6](https://github.com/microsoft/sarif-sdk/compare/fc9a9dfb865096b5aaa9fa3651854670940f7459...698adb6365a242c6bb75adde56e3bd4be39c21d7). [#674](https://github.com/microsoft/binskim/pull/674)
* Introduce first performance rule `BA6001.DisableIncrementalLinkingInReleaseBuilds` [#667](https://github.com/microsoft/binskim/pull/667)
* Introduce more performance rules `BA6002.EliminateDuplicateStrings`, `BA6004.EnableCOMDATFolding`, `BA6005.EnableOptimizeReferences`, `BA6006.EnableLinkTimeCodeGeneration` [#691](https://github.com/microsoft/binskim/pull/691)
* BUGFIX: Fix command line parameter in documents: `-Wl,z,relro` with `-Wl,-z,relro`, and `-Wl,z,now` with `-Wl,-z,now`. [736](https://github.com/microsoft/binskim/pull/736)

## **v1.9.5** [NuGet Package](https://www.nuget.org/packages/Microsoft.CodeAnalysis.BinSkim/1.9.5)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,17 +259,17 @@
"id": "BA3010",
"name": "EnableReadOnlyRelocations",
"fullDescription": {
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,relro' to enable this."
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,relro' to enable this."
},
"help": {
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,relro' to enable this."
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,relro' to enable this."
},
"messageStrings": {
"Pass": {
"text": "The GNU_RELRO segment was present, so '{0}' is protected."
},
"Error": {
"text": "The GNU_RELRO segment is missing from this binary, so relocation sections in '{0}' 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,relro' to address this."
"text": "The GNU_RELRO segment is missing from this binary, so relocation sections in '{0}' 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,relro' to address this."
},
"NotApplicable_InvalidMetadata": {
"text": "'{0}' was not evaluated for check '{1}' as the analysis is not relevant based on observed metadata: {2}."
Expand All @@ -281,17 +281,17 @@
"id": "BA3011",
"name": "EnableBindNow",
"fullDescription": {
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,now' to enable this."
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,now' to enable this."
},
"help": {
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,z,now' to enable this."
"text": "This check ensures that some relocation data is marked as read only after the executable is loaded, and moved below the '.data' section in memory. This prevents them from being overwritten, which can redirect control flow. Use the compiler flags '-Wl,-z,now' to enable this."
},
"messageStrings": {
"Pass": {
"text": "The BIND_NOW flag was present, so '{0}' is protected."
},
"Error": {
"text": "The BIND_NOW flag is missing from this binary, so relocation sections in '{0}' 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."
"text": "The BIND_NOW flag is missing from this binary, so relocation sections in '{0}' 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."
},
"NotApplicable_InvalidMetadata": {
"text": "'{0}' was not evaluated for check '{1}' as the analysis is not relevant based on observed metadata: {2}."
Expand Down
Loading