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

Conversation

shaopeng-gh
Copy link
Collaborator

More info:
https://wiki.debian.org/Hardening
via gcc with -Wl,-z,now
via gcc with -Wl,-z,relro
This change is the only change in this pr.

@@ -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 ..."

Copy link
Member

@michaelcfanning michaelcfanning left a comment

Choose a reason for hiding this comment

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

:shipit:

@michaelcfanning michaelcfanning enabled auto-merge (squash) November 14, 2022 23:57
@michaelcfanning michaelcfanning merged commit 009f87c into main Nov 15, 2022
@michaelcfanning michaelcfanning deleted the users/shaopeng-gh/fixz branch November 15, 2022 00:03
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