-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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
cmd/go: enable ASLR on Windows -buildmode=c-shared #41421
Comments
Change https://golang.org/cl/255259 mentions this issue: |
@qmuntal thank you for your report and CL. But CL 255259 makes every DLL use ASLR. What about, if some DLLs needs to be compiled the old way without ASLR? How would the developers build DLL without ASLR? We already had reports that some packages are broken when building executables with Go 1.15. These developers just use -buildmode=exe to force no ASLR build. So this problem is real. We need something similar for DLLs before we can proceed with any fix here. Alex /cc @zx2c4 |
Good point @alexbrainman , enabling ASLR on pie binaries could be justified because there is the One option could be to define an env var, p.e. GOLINK, that allow developers to opt-in or opt-out linker features, in a similar manner we already do on GOARM and GOWASM. The GOLINK values would be a predefined list of well known features, such as |
I cannot make that decision. You need to take this proposal with Go Team. Personally I think there are too many GO* variables already. Alex |
@alexbrainman I´ve updated the CL and removed the With this change the only new flags added to Also the issues I´ve seen related to go1.15 defaulting to |
What happened to msvc in 2008 is not relevant here, because Go users don't use msvc, they use gcc. And most of these are very very out of date.
Not my call, sorry. Go team need to decide that is what they want to do. Cherry can, probably, make that call. Alex |
Thanks for the feedback and the review Alex. Lets see if @rsc or @cherrymui can add something to this issue. |
Seems like we can already get a DSL with ASLR on Windows by running something like |
Good shoot, it does add ASLR and the required dllcharacteristics to the output DLL.
Unfortunately |
Option 1: We could just leave things as they are and update the documentation on how to build ASLR DLL. It is only that the flags are bit complicated. And we also want ASLR to be the default.
That is unfortunate indeed. It would be nice, if we could make ASLR the default, and document how to disable the ASLR.
I don't want to introduce new build mode or a new environment variable too. But that only leaves us with Option 1. But maybe option 1 is good enough. Alex |
We could add a Go linker option that disables ASLR, by telling the linker to not add the options that are passed to the system linker. This would then be available using something like |
Should |
I don't know what |
I agree with Ian. Lets only allow Alex |
I'll use the positive flag |
Thank you. Alex |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
go build -buildmode=c-shared -o libfoo.dll .
dumpbin /headers libfoo.dll
What did you expect to see?
I expected the dll to have
IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE
andIMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA
flags set just as if I would be building a binary with-buildmode=pie
(implemented in #35192).What did you see instead?
Current implementation doesn't use ASLR nor High Entropy which causes go dll's to by flagged by cyber-security as insecure.
This is the follow up of golang-nuts/hVK37aucmco.
@alexbrainman
The text was updated successfully, but these errors were encountered: